From 578368fce559ad28eb3bc62064e4c39858fa3339 Mon Sep 17 00:00:00 2001 From: "Fraboni, Gino (gf403a)" Date: Wed, 3 May 2017 13:47:43 -0400 Subject: [PATCH] Implement support for v10 model entities. Change-Id: Id2b42b70d7fe0ada6695ac9632b314f21ace193f Signed-off-by: Fraboni, Gino (gf403a) --- ajsc-shared-config/README.txt | 6 + ajsc-shared-config/etc/PartnerProfile.xml | 2408 ++++++++++ ajsc-shared-config/etc/aft.properties | 16 + .../etc/basic-logback_root_logger_level_off.xml | 87 + .../etc}/logback.xml | 22 +- ajsc-shared-config/etc/spm2.jks | Bin 0 -> 62008 bytes antBuild/build.xml | 231 + .../etc/appprops/AAFUserRoles.properties | 13 + .../appprops/PostProcessorInterceptors.properties | 3 + .../appprops/PreProcessorInterceptors.properties | 4 + .../etc/appprops/app-intercepts.properties | 8 + .../etc/appprops/methodMapper.properties | 10 + .../etc/sysprops/sys-props.properties | 115 + pom.xml | 219 +- .../model-loader/v1/conf/modelLoaderBeans.groovy | 31 + .../model-loader/v1/docs/README.txt | 21 + .../model-loader_v1/model-loader/v1/lib/README.txt | 21 + .../model-loader/v1/props/module.props} | 36 +- .../model-loader/v1/routes/modelLoader.route} | 39 +- src/main/assemble/ajsc_module_assembly.xml | 86 + .../ajsc_props_assembly.xml} | 63 +- src/main/assemble/ajsc_runtime_assembly.xml | 64 + .../model-loader.properties => bin/start.sh} | 76 +- src/main/config/ajsc-chef.jks | Bin 0 -> 5256 bytes src/main/config/ajsc-jetty.xml | 90 + src/main/config/ajsc-override-web.xml | 73 + src/main/config/ajscJetty.jks | Bin 0 -> 3736 bytes src/main/config/cadi.properties | 56 + src/main/config/jul-redirect.properties | 32 + src/main/config/keyfile | 27 + src/main/config/runner-web.xml | 117 + src/main/docker/.dockerignore | 2 - src/main/docker/Dockerfile | 61 +- src/main/docker/update_config.sh | 151 - .../modelloader/config/ModelLoaderConfig.java | 467 +- .../org/openecomp/modelloader/entity/Artifact.java | 90 +- .../modelloader/entity/ArtifactHandler.java | 76 +- .../openecomp/modelloader/entity/ArtifactType.java | 52 +- .../entity/catalog/VnfCatalogArtifact.java | 64 +- .../entity/catalog/VnfCatalogArtifactHandler.java | 376 +- .../modelloader/entity/model/ModelArtifact.java | 194 +- .../entity/model/ModelArtifactHandler.java | 361 +- .../entity/model/ModelArtifactParser.java | 462 +- .../modelloader/entity/model/ModelSorter.java | 468 +- .../notification/DistributionStatusMsg.java | 152 +- .../modelloader/notification/EventCallback.java | 580 +-- .../modelloader/restclient/AaiRestClient.java | 802 ++-- .../modelloader/service/ModelLoaderInterface.java | 108 +- .../modelloader/service/ModelLoaderMsgs.java | 212 +- .../modelloader/service/ModelLoaderService.java | 362 +- .../modelloader/util/JsonXmlConverter.java | 160 +- src/main/resources/aai-os-cert.p12 | Bin 4357 -> 0 bytes .../filemonitor/FileMonitorMsgs.properties | 81 - .../modelloader/service/ModelLoaderMsgs.properties | 218 +- src/main/resources/schema/aai_schema_v8.xsd | 4912 ++++++++++---------- src/main/resources/schema/vnfcatalog.xsd | 242 +- ...ame__#__module.ajsc.namespace.version__.context | 1 + src/main/runtime/context/default#0.context | 1 + ...e.name__#__module.ajsc.namespace.version__.json | 1 + src/main/runtime/shiroRole/ajscadmin.json | 1 + ...ontextadmin#__module.ajsc.namespace.name__.json | 1 + .../runtime/shiroRole/contextadmin#default.json | 1 + src/main/runtime/shiroUser/ajsc.json | 1 + src/main/runtime/shiroUserRole/ajsc#ajscadmin.json | 1 + ...ontextadmin#__module.ajsc.namespace.name__.json | 1 + .../shiroUserRole/ajsc#contextadmin#default.json | 1 + .../modelloader/config/ModelLoaderConfigTest.java | 247 +- .../catalog/VnfCatalogArtifactHandlerTest.java | 198 +- .../entity/model/ModelArtifactParserTest.java | 356 +- .../modelloader/entity/model/ModelSorterTest.java | 271 +- ...IRestClientTest.java => AaiRestClientTest.java} | 240 +- .../service/ModelLoaderServiceTest.java | 115 - .../modelloader/util/JsonXmlConverterTest.java | 160 +- src/test/resources/logback-test.xml | 62 +- .../model-loader-empty-auth-password.properties | 74 +- .../model-loader-no-auth-password.properties | 70 +- src/test/resources/model-loader.properties | 74 +- ...I-Testvsp..vmme_cinder..module-1-resource-1.xml | 52 + ...tvsp..vmme_small_ecomp..module-0-resource-1.xml | 180 + src/test/resources/models/AAI-VL-resource-1.xml | 52 + .../models/AAI-stellService-service-1.xml | 89 + .../resources/models/AAI-testvsp-resource-1.xml | 89 + src/test/resources/models/complete-model.xml | 515 +- .../resources/models/incomplete-model.xml} | 65 +- src/test/resources/models/incomplete-models.xml | 50 + src/test/resources/models/invalid-model.xml | 51 + src/test/resources/models/l3-network-widget.json | 14 + .../resources/models/l3-network-widget.xml} | 48 +- .../resources/models/named-query-wan-connector.xml | 168 +- src/test/resources/models/vnf-model.json | 10 - src/test/resources/models/wan-connector-model.xml | 185 - src/test/resources/vnfcatalogexample.xml | 286 +- version.properties | 54 +- 93 files changed, 11330 insertions(+), 7082 deletions(-) create mode 100644 ajsc-shared-config/README.txt create mode 100644 ajsc-shared-config/etc/PartnerProfile.xml create mode 100644 ajsc-shared-config/etc/aft.properties create mode 100644 ajsc-shared-config/etc/basic-logback_root_logger_level_off.xml rename {src/main/resources => ajsc-shared-config/etc}/logback.xml (86%) create mode 100644 ajsc-shared-config/etc/spm2.jks create mode 100644 antBuild/build.xml create mode 100644 bundleconfig-local/etc/appprops/AAFUserRoles.properties create mode 100644 bundleconfig-local/etc/appprops/PostProcessorInterceptors.properties create mode 100644 bundleconfig-local/etc/appprops/PreProcessorInterceptors.properties create mode 100644 bundleconfig-local/etc/appprops/app-intercepts.properties create mode 100644 bundleconfig-local/etc/appprops/methodMapper.properties create mode 100644 bundleconfig-local/etc/sysprops/sys-props.properties create mode 100644 src/main/ajsc/model-loader_v1/model-loader/v1/conf/modelLoaderBeans.groovy create mode 100644 src/main/ajsc/model-loader_v1/model-loader/v1/docs/README.txt create mode 100644 src/main/ajsc/model-loader_v1/model-loader/v1/lib/README.txt rename src/main/{docker/startup.sh => ajsc/model-loader_v1/model-loader/v1/props/module.props} (84%) rename src/{test/resources/models/vnf-model.xml => main/ajsc/model-loader_v1/model-loader/v1/routes/modelLoader.route} (78%) create mode 100644 src/main/assemble/ajsc_module_assembly.xml rename src/main/{webapp/WEB-INF/rest-servlet.xml => assemble/ajsc_props_assembly.xml} (56%) create mode 100644 src/main/assemble/ajsc_runtime_assembly.xml rename src/main/{resources/model-loader.properties => bin/start.sh} (51%) create mode 100644 src/main/config/ajsc-chef.jks create mode 100644 src/main/config/ajsc-jetty.xml create mode 100644 src/main/config/ajsc-override-web.xml create mode 100644 src/main/config/ajscJetty.jks create mode 100644 src/main/config/cadi.properties create mode 100644 src/main/config/jul-redirect.properties create mode 100644 src/main/config/keyfile create mode 100644 src/main/config/runner-web.xml delete mode 100644 src/main/docker/.dockerignore delete mode 100644 src/main/docker/update_config.sh delete mode 100644 src/main/resources/aai-os-cert.p12 delete mode 100644 src/main/resources/org/openecomp/modelloader/filemonitor/FileMonitorMsgs.properties create mode 100644 src/main/runtime/context/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.context create mode 100644 src/main/runtime/context/default#0.context create mode 100644 src/main/runtime/deploymentPackage/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.json create mode 100644 src/main/runtime/shiroRole/ajscadmin.json create mode 100644 src/main/runtime/shiroRole/contextadmin#__module.ajsc.namespace.name__.json create mode 100644 src/main/runtime/shiroRole/contextadmin#default.json create mode 100644 src/main/runtime/shiroUser/ajsc.json create mode 100644 src/main/runtime/shiroUserRole/ajsc#ajscadmin.json create mode 100644 src/main/runtime/shiroUserRole/ajsc#contextadmin#__module.ajsc.namespace.name__.json create mode 100644 src/main/runtime/shiroUserRole/ajsc#contextadmin#default.json rename src/test/java/org/openecomp/modelloader/restclient/{AAIRestClientTest.java => AaiRestClientTest.java} (92%) delete mode 100644 src/test/java/org/openecomp/modelloader/service/ModelLoaderServiceTest.java create mode 100644 src/test/resources/models/AAI-Testvsp..vmme_cinder..module-1-resource-1.xml create mode 100644 src/test/resources/models/AAI-Testvsp..vmme_small_ecomp..module-0-resource-1.xml create mode 100644 src/test/resources/models/AAI-VL-resource-1.xml create mode 100644 src/test/resources/models/AAI-stellService-service-1.xml create mode 100644 src/test/resources/models/AAI-testvsp-resource-1.xml rename src/{main/webapp/WEB-INF/web.xml => test/resources/models/incomplete-model.xml} (56%) create mode 100644 src/test/resources/models/incomplete-models.xml create mode 100644 src/test/resources/models/invalid-model.xml create mode 100644 src/test/resources/models/l3-network-widget.json rename src/{main/webapp/WEB-INF/applicationContext.xml => test/resources/models/l3-network-widget.xml} (61%) delete mode 100644 src/test/resources/models/vnf-model.json delete mode 100644 src/test/resources/models/wan-connector-model.xml diff --git a/ajsc-shared-config/README.txt b/ajsc-shared-config/README.txt new file mode 100644 index 0000000..a82eb64 --- /dev/null +++ b/ajsc-shared-config/README.txt @@ -0,0 +1,6 @@ +The ajsc-shared-config folder is included in the service project to provide the functionality of the AJSC_SHARED_CONFIG +location that will exist in CSI envs. This includes the logback.xml for logging configurations, and some csm related +artifacts necessary for proper functionality of the csm framework within the CSI env. Within the 2 profiles that can +be utilized to run the AJSC locally, "runLocal" and "runAjsc", the system propery, "AJSC_SHARED_CONFIG", has been set +to point to this directory. The files in this folder will NOT be copied/moved anywhere within the AJSC SWM package. These +files will already be in existence within the CSI env. \ No newline at end of file diff --git a/ajsc-shared-config/etc/PartnerProfile.xml b/ajsc-shared-config/etc/PartnerProfile.xml new file mode 100644 index 0000000..de9ca07 --- /dev/null +++ b/ajsc-shared-config/etc/PartnerProfile.xml @@ -0,0 +1,2408 @@ + + + + + + + sg7477 + 2013-06-30T00:06:07+05:30 + + + + + + + 100 + 110 + + + AddAccount + + 10 + + + + AddNote + + 90 + 110 + + + + + + 5000 + 300000 + 600000 + + + AddNote + + 5000 + 250000 + 300000 + + + + CreateFiberServiceVOIPNumber + + 120000 + 300000 + 300000 + + + + InquireAccountProfile + + 5000 + 100000 + 250000 + + + + InquireUnbilledUsageDetail + + 5000 + 250000 + 300000 + + + + InquireWirelinePortEligibility + + 5000 + 330000 + 600000 + + + + QualifyAndQuoteFiberServiceProducts + + 120000 + 300000 + 300000 + + + + SendSms + + 5000 + 150000 + 180000 + + + + ValidateFiberServiceFacility + + 120000 + 1200000 + 1200000 + + + + ValidateFiberServiceFacilityResponse + + 120000 + 1200000 + 1200000 + + + + ExecuteWirelineMechanizedLoopTest + + 120000 + 1200000 + 1200000 + + + + ExecuteWirelineMechanizedLoopTestResponse + + 120000 + 1200000 + 1200000 + + + + AppDev_NetworkPerformance + + 60000 + 100000 + 250000 + + + + + BW + + 25 + 10 + 10 + 10 + 10 + + csitest + testingcsi + csitest + false + false + WALMART + false + + 500 + 300000 + 600000 + + + accountdetails + v1 + get + + + AddContentProviderSponsor + + + AddEmployeeDetails + + + InquireEmployeeDetails + + + InquireVoiceUsageDetails + + + UpdateContentProviderSponsor + + + InquireContentProviderSponsor + + + InquireCircuitTestResults + + + InquireAccountProfileV78 + + + InquireSubscriberProfileV78 + + + ScheduleCircuitTest + + + CancelScheduledCircuitTest + + + InquireAvailableCircuitTestList + + + SubmitCircuitTest + + + InquireCustomerTroubleTicketDetails + + + UpdateCustomerTroubleTicketDetails + + + AddCustomerTroubleTicket + + + ManageBusinessServices + + + InquireMobileUsageDetails + + + UpdateEnterpriseEndUserPermissions + + + SwapCrossUpgradeEquipment + + + ManageMobilePaymentProfile + + + InquireCustomerAlarmList + + + InquireCustomerAlarmCount + + + UpdateCustomerAlarmAcknowledgment + + + InquireRatingModel + + + InquireCustomerPurchaseEligibility + + + InquireCustomerTroubleTicketList + + + InquireCustomerTroubleTicketCount + + + InquireResellerAccountProfile + + + SubmitResellerContractInformation + + + InquireInternationalOfferings + + + InquireAccessCircuitSummary + + + InquireEnterpriseOrderDetails + + + InquireEnterpriseOrderList + + + InquireEnterpriseOrderStatus + + + InquireEthernetDetails + + + InquireCustomerDigitalLifeInstallationProfile + + + InquireDirectoryListingHeadings + + + ManageDigitalLifeDevice + + + SendDigitalLifeDeviceNotification + + + ExecuteWirelineMechanizedLoopTest + + + ExecuteWirelineMechanizedLoopTestResponse + + + InquireNetworkAssetDetails + + + InquireVOIPProbeDetails + + + InquireVOIPAssetDetails + + + InquireManagedAssetDetails + + + ExecuteExternalIdVerificationQA + + + InquireIPNetworkServiceLocationDetails + + + InquireUnifiedCreditCheckResult + + + ProcessDeviceUnlock + + + InquireWirelessDashboard + + + InquireWirelineServiceAppointmentReservations + + + UpdateWirelineServiceAppointmentReservation + + + InquireTechnicianDispatchStatus + + + UpdateIDDBAutoGroup + + + UpdateIDDBDailyRules + + + UpdateIDDBGeography + + + UpdateIDDBMasterTemplate + + + ValidateOpenDeviceEligibility + + + ValidateOpenDeviceEmailAddressAvailability + + + RetrieveAvailableOpenDeviceProducts + + + RetrieveOpenDeviceDetails + + + ValidateAndQualifyOpenDeviceAddress + + + RetrieveOpenDeviceTax + + + CreateOpenDeviceCustomer + + + CreateOpenDeviceCustomerOrder + + + AddRetailStoreAppointment + + + ValidateAddressServiceAvailability + + + InquireAvailableRetailStoreAppointments + + + InquireRetailStoreAppointmentReferenceDetails + + + UpdateFanProfile + + + InquireRetailStoreAppointmentList + + + InquireKeyValueStore + + + UpdateKeyValueStore + + + AppDev_NetworkPerformance + wireless + get + + + InquireUnifiedCustomerIdentifiers + + + InquireNetworkLatency + + + InquireNetworkTrafficDensity + + + InquireReferenceCodeList + + + InquireBillList + + + InquireSubscriberBilledCallDetails + + + InquireSubscriberCharges + + + InquireSubscriberHistory + + + InquireSwitchCircuitDetails + + + InquireSwitchCircuitList + + + AddBillAccounts + + + AddUCOrder + + + OrderDeviceProtectionPlan + + + ResetEwalletSecurityProfile + + + UpdateCustomerSalesSupportDetails + + + UpdatePartnerServicesProductStatus + + + UpdateSubscriberParentalControls + false + + + InquireOrderDetails + + + UpdateCPEDetails + + + InquireNonSBSInventory + + + UpdateUCCustomerProfile + + + InquireUCCustomerProfile + + + CreateUCCustomerNumber + + + AuthorizeLOAUpdate + + + ReleaseInquiredTelephoneNumbers + + + ValidateTelephoneNumbers + + + UpdateLOADetails + + + ValidateOrder + + + UpdateBVOIPSiteProfile + + + InquireUpsellEligibility + + + InquireIncompatibleOfferings + + + UpdateBVOIPSubscriberAssociation + + + SendBVOIPSubscriberAssociationNotification + + + CreateWirelineServiceOrder + + + InquireWirelineDirectoryAvailability + + + InquireAvailableCustomerSparePairsSummary + + + UpdateUnifiedCustomerLoginProfile + + + InquireEnterpriseDetails + + + InquirePaymentProductApplicationResult + + + InquireTroubleTicketStatus + + + InquireTroubleReferenceDetails + + + InquireTroubleTicketHistory + + + UpdateTroubleTicketDetails + + + AddEnterpriseTroubleTicket + + + InquireContractTerminationDetails + + + UpdatePaymentPreferences + + + InquireWirelineServiceAppointments + + + ReserveWirelineServiceAppointment + + + InquireWirelinePendingOrderDetails + + + SubmitWirelineFacilityAssignmentOrder + + + InquireWirelinePendingOrderDetailsResponse + + + AddTroubleTicket + + + InquireFemtocellDevice + + + UpdateFemtocellDevice + + + SendTroubleTicketStatusNotice + + + InquireWirelineTechnicianAssignments + + + InquireAvailableFiberServiceAppointments + + + SubmitMechanizedLoopTest + + + InquirePortedTNList + + + InquireWirelinePortDetails + + + InquireHostRoutingDetails + + + InquireBundledOrder + + + InquireBundledAccountServices + + + UpdateBundledAccountServices + + + UpdateWirelineWorkOrder + + + InquireSubscriberCallList + + + UpdateSubscriberCallList + + + ValidateCreditPolicy + + + AddPaymentProfile + true + + + ActivateSwitchFeatures + + + AddTechnicianTroubleNote + + + UpdatePaymentProfile + true + + + InquireSBSBundledDiscountSubscriberList + + + ExchangePerformanceMetrics + + + InquireBundledOrderStatus + + + InquireAvailableBundlePackages + + + InquireBundledOrderList + + + DeletePaymentProfile + + + UpdateBillingPreferences + + + SendBillingPreferencesNotification + + + InquirePaymentProfile + + + InquireServiceAvailabilityForLocation + + + ActivateCustomer + + + ActivateDevice + + + ActivateFemtocellService + + + ActivateFiberServiceResidentialGateway + + + ActivateFiberServiceTNPort + + + ActivatePendingEquipmentUpgrade + + + ActivateSubscriber + + + ActivateSubscriberReseller + + + ActivateSubscriberResellerResponse + + + ActivateSubscriberResponse + + + Add3PPOrderNotes + + + Add3PPOrderShipment + + + AddAccount + + 25 + + + + AddAffiliateDiscount + + + AddATTConnectAccount + + + AddCombinedBilling + + + AddCreditPolicyProfile + + + AddCustomerDeviceSalesData + + + AddBundledOrder + + + UpdateBundledOrder + + + AddFemtocellAddress + + + AddFemtocellCALEALocation + + + AddFemtocellProfile + + + AddFiberServiceAccount + + + AddFiberServiceCreditPolicy + true + + + AddFiberServiceTNPort + + + AddInsuranceClaimOrder + + + AddNetworkElementTroubleReport + + + AddNote + + + AddOrderEmail + + + AddOtherChargesCredits + + + AddPayment + true + + + AddPort + + + AddPrepaidFeature + + + AddPrepaidPayment + + 5000 + 300000 + 300000 + + + + AddPromiseToPay + + + AddRemoveProductCodeIndicator + + + AddSbcCombinedBilling + + + AddSbcSaleInformation + + + AddSmsPayment + + + AddWirelineNote + + + AddWirelineOrder + + + AddWirelinePayment + true + + + AddWirelinePaymentPlan + true + + + ApplyDataTreatment + + + ApplyFiberServiceCreditPolicy + + + ApplyPrepaidPayment + + + ApplyPrepaidVoucher + + + AuthenticateFanPassword + + + AuthenticateFanPin + + + AuthorizeCreditCard + true + + + CalculateSatelliteServiceTaxes + + + CalculateTaxes + + + Cancel3PPOrder + + + CancelCombinedBilling + + + CancelCopay + + + CancelFemtocellE911Service + + + CancelFemtocellNetwork + + + CancelFemtocellService + + + CancelFiberServiceWorkOrder + + + CancelHLRRegistration + + + CancelInsuranceClaimOrder + + + CancelPendingEquipmentUpgrade + + + CancelPort + + + CancelReservedFiberServiceVOIPNumber + + + CancelWirelinePayment + + + ChangeSubscriberNumber + + + CheckEligibility + + + ConfirmHLRRegistration + + + ConfirmWirelineTNReservation + + + CreateFiberServiceAccount + + + CreateFiberServiceVOIPNumber + + + CreateFiberServiceWorkOrder + + + CreateSatelliteServiceOrder + + + DeleteFemtocellAddress + + + DeleteFemtocellProfile + + + DetermineFiberServiceAccountHistoryList + + + DetermineFiberServiceDuplicateApplicationList + + + Echo + + + ExecuteAffiliateCreditCheck + + + ExecuteCreditCheck + + + ExecuteFiberServiceCreditCheck + + + ExecuteNBIMigration + + + ExecuteSalesOpportunityCreditCheck + + + ExecuteWirelineCreditCheck + + + ExecuteWirelineTroubleReportFunction + + + Generic + + + InitiateFiberServiceOrder + + + InitiateUnifiedCreditPolicyRetrieval + + + InquireAccessoryPricing + + + InquireAccountList + true + + + InquireAccountPaymentHistory + + + InquireAccountProfile + true + + + InquireAccountSubscribers + + + InquireActivationCommissionCodes + + + InquireAdditionalOfferings + + + InquireAddressMatch + + + InquireAffiliateAccountPaymentBalance + + + InquireAffiliateAccountProfile + + + InquireAffiliateCustomerAccount + + + InquireAffiliateEligibility + + + InquireAffiliateGeneralMessages + + + InquireAffiliateOrderStatus + + + InquireAffiliateProductCatalog + + + InquireAffiliateProductConfiguration + + + InquireAffiliateProductDetails + + + InquireAffiliateProductOfferingEligibility + + + InquireAffiliateServiceQualification + + + InquireAffiliateServiceScheduling + + + InquireARRemittance + + + InquireATTCreditCardOffer + + + InquireATTCreditCardOfferList + + + InquireAutomaticPayment + true + + + InquireAvailableAccessory + + + InquireAvailableFiberServiceAppointments + + + InquireAvailableCircuitSparePairs + + + InquireAvailableDevice + + + InquireAvailableFees + + + InquireAvailableFiberServiceAppointments + + + InquireAvailableFiberServiceCustomers + + + InquireAvailableFiberServiceVOIPNumbers + + + InquireAvailableItemQuantity + + + InquireAvailableOfferDetails + + + InquireAvailableOffers + + + InquireAvailablePortInSubscriber + + + InquireAvailableSatelliteServiceAppointments + + + InquireAvailableSubscriberNumbers + + + InquireCollectionData + + + InquireCombinedBillingEligibility + true + + + InquireContractedConversionFee + + + InquireCopayEligibility + + + InquireCopaySubscriber + + + InquireCopaySubscriberHistory + + + InquireCPNIContactInformation + + + InquireCpniPreferenceHistory + + + InquireCreditCheckResult + + + InquireCreditPolicyProfile + + + InquireCustomerDeviceSalesData + + + InquireDataAccessEligibility + + + InquireDataTreatmentHistory + + + InquireDepositPaymentStatus + + + InquireDeviceDetails + + + InquireDeviceShippingInformation + + + InquireDuplicateOfferings + + + InquireEquipmentOrder + + + InquireEquipmentOrderInvoice + + + InquireEquipmentPricing + + + InquireEstimatedFulfillmentTime + + + InquireExistingCustomer + + + InquireFanProfile + + + InquireFemtocellAddressList + + + InquireFemtocellDeviceList + + + InquireFemtocellEligibility + + + InquireFemtocellProfile + + + InquireFiberServiceAccountDetails + + false + + + InquireFiberServiceAssignedProductDetails + + + InquireFiberServiceCircuitDetails + + + InquireFiberServiceCreditVerificationQuestions + + + InquireFiberServiceCrossProductPackages + + + InquireFiberServiceEquipmentDetails + + + InquireFiberServiceOfferEligibility + + + InquireFiberServiceOrderDetail + + + InquireFiberServiceOrderList + + + InquireFiberServiceOrderStatus + + + InquireFiberServiceProductDetails + + + InquireFiberServiceQualification + + + InquireFiberServiceQuotation + + + InquireFiberServiceSubscriptionAccount + + + InquireFiberServicePendingAdjustments + + + InquireFiberServiceTNPortStatus + + + InquireFiberServiceUsageDetails + + + InquireFiberServiceVOIPPortEligibility + + + InquireInsuranceClaimOrder + + + InquireInsuranceClaimReplacementProducts + + + InquireInternationalRoamingMinutes + + + InquireInternationalRoamingUsageParameters + + + InquireLandLinePaymentServiceFee + + + InquireLastSuccessfulPayment + true + + + InquireMarketByZip + + + InquireMarketServiceAreas + + + InquireMaximumDryLoopFTNAllowed + + + InquireMessagingCapabilities + + + InquireNBIMigrationEligibility + + + InquireOfferHistory + + + InquireOfferingEligibility + + + InquireOTAHistory + + + InquireOTAProfile + + + InquirePaymentLocationDetails + + + InquirePendingPricePlan + + + InquirePort + + + InquirePortActivationStatus + + + InquirePortEligibilityByRange + + + InquirePortEligibilityBySubscriberNumber + + + InquirePrepaidBalance + + + InquirePrepaidFeatures + + + InquirePrepaidFeaturesHistory + + + InquirePrepaidPaymentEligibility + + + InquirePrepaidPricePlans + + + InquirePrepaidPINDetails + + + InquirePrepaidSubscriberProfile + + + InquirePricePlanList + + + InquirePricePlans + + + InquirePurchaseOrder + + + InquireSatelliteServiceOrderDetails + + + InquireSatelliteServiceProducts + + + InquireSatelliteServiceQualification + + + InquireSatelliteServiceQuotation + + + InquireSbcCombinedBillingEligibility + + + InquireServiceAreaByZip + + + InquireServiceOrderActivationStatus + + + InquireSharedGroupUpdateStatus + + + InquireShippingZipBySubscriberNumber + + + InquireSIMStatus + + + InquireSubscriberList + + + InquireSubscriberParentalControls + + + InquireSubscriberPin + + + InquireSubscriberProfile + true + + + InquireSubscriberServiceStatus + + + InquireSubscriberTransactionData + + + InquireSubscriptionAccountIdentifiers + + + InquireWirelineSwitchProfile + + + InquireSwitchTransactionStatus + + + InquireUnbilledUsageDetail + + + InquireUnifiedCustomerProfileByServiceLocation + + + InquireUnifiedCustomerServiceProfile + + + InquireUpgradeEligibility + + + InquireUnifiedOrderDetails + + + InquireWiFiEligibility + + + InquireWirelineAccountProfile + + + InquireWirelineAccountAssociations + + + InquireInternetSubscriptionAccounts + + + InquireWirelineBillingAccountList + + + InquireWirelineCreditApplicationList + + + InquireWirelineCreditVerificationQuestions + + + InquireWirelineCustomerAccount + + + InquireWirelineDSLandConnectTechOrderDetail + + + InquireWirelineDTVOrderDetail + + + InquireWirelineFiberServiceAppointments + + + InquireWirelineGeneralMessages + + + InquireWirelineNetworkChannelDetails + + + InquireWirelineNonRecurringCharges + + + InquireWirelineOpenTroubleReports + + + InquireWirelineOrderDetails + + + InquireWirelineOrderStatus + + + InquireWirelinePaymentHistory + + + InquireWirelinePaymentPlan + true + + + InquireWirelinePortEligibility + + + InquireAvailableTelephoneNumbers + + + ReserveTelephoneNumbers + + + InquireWirelineProductCatalog + + + InquireWirelineProductConfiguration + + + InquireWirelineProductCount + + + InquireWirelineProductDetails + + + InquireWirelineProductsForResource + + + InquireWirelineRegion + + + InquireWirelineServiceQualification + + + InquireWirelineServiceScheduling + + + InquireWirelineQualifiedProducts + + + InquireWirelineServiceOrderDetails + + + InquireWirelineTelcoOrderDetail + + + InquireWirelineTransportDetails + + + InquireWirelineUsageDetail + + + InquireWirelineWholesaleProductFamilies + + + MaintainAffiliateAccountAssociation + + + ManageAutomaticPayments + true + + + ManageCopay + + + ManageSubscriberPin + + + ModifySatelliteServiceOrder + + + CancelSatelliteServiceOrder + + + MoveSubscriber + + + NotifyFemtocellAction + + + OrderEquipment + + + OrderEquipmentWithValidation + + + OrderFiberService + + + ParseUnfieldedWirelineAddress + + + PortFiberServiceTelephoneNumber + + + ProcessEcho + + + ProcessEchoBackOffice + + + ProcessEchoFrontOffice + + + ProcessWirelineCPNIElection + + + ProvisionAddressBookService + + + ProvisionFemtocellE911Service + + + ProvisionFemtocellNetwork + + + ProvisionFemtocellRegistration + + + PublishUnifiedCreditPolicy + + + QualifyAndQuoteFiberServiceProducts + + + QualifyProducts + + + RegisterFemtocellService + + + ReleaseAvailableFiberServiceVOIPNumbers + + + ReleaseDryLoopFTN + + + ReleaseSubscriberNumber + + + RemoveCustomerDeviceSalesData + + + ResendOTAProfile + + + ReserveFiberServiceAppointments + + + ReserveFiberServiceVOIPNumber + + + ReserveSubscriberNumber + + + ResetVoiceMailPassword + + + RetrieveAbandonedFiberServiceOrder + + + RetrieveFiberServiceAccount + + + RetrieveFiberServiceAppointments + + + RetrieveFiberServiceOrderStatus + + + RetrieveFiberServiceProducts + + + RetrieveOrderDetails + + + RetrieveProducts + + + RetrieveQuotation + + + RetrieveUnifiedCreditPolicy + + + ScheduleAppointments + + + ScheduleSatelliteServiceInstallation + + + SendAccountNotification + + + SendCPNINotification + + + SendEmail + + + SendFanProfileNotification + + + SendFiberServiceTNPortNotification + + + SendFiberServiceWorkOrderNotification + + + SendFiberServiceWorkOrderNotificationAsync + + + SendSms + + + SendSmsResponse + + + SendTreatmentNotification + + + SubmitATTCreditCard + + + SubmitCreditCheck + + + SubmitFiberServiceOrder + + + SubmitFiberServiceTNAssignmentOrder + + + SubmitOrder + + + SubmitWalmartProxy + + + SwapEquipment + + + SwapFemtocellDevice + + + UpdateAccountDisputeDetails + + + UpdateAccountManager + + + UpdateAccountProfile + true + + + UpdateAccountStatus + + + UpdateAffiliateProductOffering + + + UpdateBillMedia + + + UpdateCpniPreference + + + UpdateCreditPolicyProfile + + + UpdateDepositPaymentStatus + + + UpdateDeviceInventory + + + UpdateDeviceProfile + + + UpdateEwalletStatus + + + InquireEwalletEventHistory + + + InquireEwalletSubscriberProfile + + + InquireCustomerSnapshot + + + UpdateFemtocellCALEALocation + + + UpdateFemtocellProfile + + + UpdateFiberServiceAccount + + + UpdateFiberServiceAccountDetails + + + UpdateFiberServiceCreditApplication + + + UpdateInternationalRoamingUsageParameters + + + UpdateOfferDisposition + + + UpdatePort + + + UpdatePrepaidFeature + + + UpdatePrepaidSubscriberProfile + + + UpdateSalesOpportunityCreditCheck + + + UpdateSatelliteServiceAccountAssociation + + + UpdateSubscriberAddressBookIdentifier + + + UpdateSubscriberProfile + + 5000 + 100000 + 120000 + + + + UpdateSubscriberStatus + + + UpdateVoiceMailProfile + + + UpdateWirelineAccountProfile + + + UpdateWirelineCPNIPreference + + + UpdateWirelineCreditApplication + + + UpdateWirelineTroubleReport + + + UpgradeEquipment + + + UpqueryAffiliateOfferingEligibility + + + ValidateAddress + + + ValidateAffiliateCustomer + + + ValidateAffiliateOrder + + + ValidateCreditCard + + + ValidateFemtocellCoverageArea + + + ValidateFemtocellE911Coverage + + + ValidateFemtocellEquipmentIdentifier + + + ValidateFemtocellWhitelist + + + ValidateFiberServiceCreditPolicy + + + ValidateFiberServiceCreditVerificationAnswers + + + ValidateFiberServiceFacility + + + ValidateFiberServiceFacilityResponse + + + ValidateFiberServiceFacilityNotification + + + ValidateFiberServiceProductDetails + + + ValidateSatelliteServiceProducts + + + ValidateShippingPriority + + + ValidateWirelineCreditVerificationAnswers + + + ValidateWirelineCustomer + + + ValidateWirelineOrder + + + InquireWirelineFutureAvailability + + + ValidateWirelinePostalAddress + + + CancelMobileContent + + + InquireMobileContentDetails + + + UpdateFiberServiceOrder + + + ExecuteUnifiedCreditCheck + + + SendPaymentProductApplicationResultNotification + + + ConfirmUnifiedCreditAccountDebtPayment + + + InquireUnifiedCreditAccountDebtDetails + + + InquireUnifiedCreditVerificationQuestions + + + SubmitUnifiedCreditApplication + + + UpdateUnifiedCreditApplication + + + ValidateUnifiedCreditVerificationAnswers + + + InquireUnifiedCreditAdverseActionLetter + + + InquireUnifiedCreditPolicyDecision + + + NotifyUnifiedCreditOrderSubmission + + + AssignAvailableWorkOrder + + + SendNetworkPathWorkOrderStatusNotification + + + ProcessNetworkPathWorkOrder + + + CreateCentralOfficeWorkOrder + + + UpdateCentralOfficeWorkOrder + + + CreateFiberServiceRepairWorkOrder + + + CreateFiberServiceRepairWorkOrderAsnyc + + + SendRepairWorkOrderNotification + + + CancelFiberServiceRepairWorkOrder + + + CancelFiberServiceRepairWorkOrderAsnyc + + + InquireUnifiedCustomerLoginProfile + + + InquireCustomerSubscriptionDetails + + + SendCancelWorkOrderNotification + + + InquireWirelineAccountLevelCSR + + + InquireWirelineServiceLevelCSR + + + InquireUnifiedPaymentProfile + true + + + UpdateCloudServiceDetails + + + InquireNote + + + ValidateSubscriberOfferings + + + AddBundledOrderV48 + + + UpdateBundledAccountServicesV48 + + + UpdateBundledOrderV48 + + + ValidateBundledOrder + + + InquireBundledAccountProfile + + + InquireRecommendationDetails + + + InquireEnterpriseEndUserPermissions + + + InquireNCIMigrationEligibility + + + ExecuteNCIMigration + + + UpdateCommonOrder + + + InquireBillCycleDetails + + + InquireCommonOrderListDetails + + + ValidateWirelineTroubleReportCompletion + + + InquireSubscriberContractDetails + + + ExecuteExternalCreditCheck + + + InquireExternalApplicantKey + + + UpdateExternalCreditApplication + + + SendExternalCreditResultNotification + + + InquireAvailableRetailStoresByLocation + + + UpdateEnterpriseEndUserPermissions + + + InquireSubscriberServiceEligibility + + + UpdateFemtocellWhiteLists + + + InquireNetworkProductCatalog + + + InquireNetworkProductPriceQuote + + + SubmitSLACreditClaim + + + InquireSLACreditClaimStatus + + + InquireSLANetworkCreditClaimStatus + + + WHOLESALE-CUSTOMER-IDDELETE + walmartID + + + WHOLESALE-CUSTOMER-NAME + walmart + + + WHOLESALE-CUSTOMER-RESTRICTED-STATES + alaska + + + BID_ID + PlatinumSP + + + EBM_ORGID + o3hevdtz + + + REMOTE-CALL + true + + + CALL_NUMERITRACK + true + + + HEARTBEAT-INTERVAL + 20 + + + AP-CALL-RSN-FOR-WLNP-TLG + false + + + AS-PROCESS-DISCOUNTS + false + + + AS-RETRY-ON-TRANSIENT-ERROR + true + + + AS-STORE-MARKET + true + + + CATALOG_TYPE + WALMART Catalog + + + + CHECK-FOR-MARKETLOOKUP-SOFTERROR + true + + + EQUIPMENT-UPGRADE-MAX-RETRY-INTERVAL + 0 + + + EQUIPMENT-UPGRADE-TRACKING-REQUIRED + false + + + IAL-AV-REQUIRED + false + + + IAP-ALLOWED-MASK-VALUES + CR:TD:SL:SN:SC:DC:UD:VU:VU+PT:VU+PR:VU+PT+PR:DU:DU+PR:UE + + + IAP-AV-REQUIRED + false + + + INFO-RESTRICT-LEVEL + Unrestricted + + + ISP-ALLOWED-MASK-VALUES + DI:DC:UD:VU:VU+PT:VU+PR:VU+PT+PR:DU:DU+PR:UE + + + IUCSP-MAX-ALLOWED-CTNS + 10 + + + IUCSP-NEW-KIT-WARRANTY-DAYS + 366 + + + IUCSP-REFURBISHED-KIT-WARRANTY-DAYS + 90 + + + IUCSP-SEED-KIT-WARRANTY-DAYS + 366 + + + IUUD-ALLOWED-MASK-VALUES + VU:VU+HO:VU+RO:VU+TO:VU+AL:VU+PT:VU+PT+HO:VU+PT+RO:VU+PT+TO:VU+PT+AL:VU+PR:VU+PR+HO:VU+PR+RO:VU+PR+TO:VU+PR+AL:VU+PT+PR:VU+PT+PR+HO:VU+PT+PR+RO:VU+PT+PR+TO:VU+PT+PR+AL:DU:DU+PR + + + IWPE-LSR11-ACCESS-DENIED + false + + + TN-REQUEST-CATEGORY + MCSICVOIP + + + MARKET-STATUS-LOOKUP + false + + + MEMO-NOTE-USER + WEB + + + NBI-ACCESS-DECLINED + false + + + PREAUTHORIZED-CREDIT-CHECK + true + + + + RESTRICTED-TO-TEST-CALLS + true + + + RESELLER-TEST-DEALER-CODE + IJX57 + + + UPGRADE-EQUIPMENT-NEW-SALES-CHANNEL + U2 + + + UPGRADE-EQUIPMENT-UPGRADE-SECURITY-CODE + III + + + USE-GENERIC-ASYNC-RESPONSE + true + + + USOC-INFO-DATA-SOURCE + CURRENT + + + VFSF-OAT-REQUIRED-MSG-LOOKUP + false + + + VFSF-CLIENT-REQ-TYPE + Negotiation + + + VFSF-CLIENT-ID + BBNMS + + + SMS-DESTINATION-PORT + -1 + + + CTVCODE-SERVICE-MAINTENANCE + true + + + XI-APPLICATION-CONTEXT + OPSS + + + IN-MAX-BILLING-NOTE-QUANTITY + 300 + + + ITTH-TL-MAX-RECORDS-TO-FETCH + 50 + + + ITTH-ITH-MAX-RECORDS-TO-FETCH + 30 + + + IEEUP-SYSTEM-ID + premier + + + SUBSCRIPTION_CLASS + S + + + MOBILE_PAYMENTS_PARTNER_ID + S + + + + IUCPBYSL-GRID-CLIENT + true + + + APPLICATION_ID + ONSTAR + + + AES + NRETLTEL + NRETLTEL + + + BOSS + testcsi + + + RACFID + pb1975 + + + RACFPASSWORD + Light@1 + + + + + BSTECSC + CSI + a2p2!!b1 + + + CAM + CSIQC + CSIQC + + AccountType + S + + + SubAccountType + T + + + WaiveActivationFee + true + + + WaiveUpgradeFee + true + + + + CBS + ZCINGP1 + + + + CPSOS + c48794 + 7941!c48 + + + DLC + CSIQC + + + DLC_APP_ID + ASURION + + + + GCS + CSIQC + + + GCS_MERCHANT_ID + 001342 + + + + InterconnectRC + csitest + + + interconnectUSERID + SBC001T + + + interconnectPASSWORD + GC@\u0011W4\#""6/\u001172OK + + + interconnectLightSpeedUSERID + SBC002T + + + interconnectLightSpeedPASSWORD + GAN\u0016T4\#""6/\u001072OK + + + interconnectConsumerUSERID + SBC003T + + + interconnectConsumerPASSWORD + GCC\u0017P4\#""6/\u001372OK + + + + LNPSOA + + + + LNPSOA_APP_ID + QC + + + + + MRE + OPUS + OPUS + + + NSM + ACME + + + + OrderTrack + csitest + + + + PDC + RS + + + + QPAY + CSI_FDC + CSI_FDC + + + SWOT-LITE + cingultest + j9WWuopev9 + + + TLGAPI + rimprov1 + unix11 + + APP_ID + TLGAPI + + + CALLER_IND + FR + + + + YODA + WTS + CSITest + + + EDGE + WMS + WMS + + + true + + 30000 + 3 + 3000 + + + false + false + + /opt/app/sg_q7/tibco/jre/lib/security/cacerts + changeit + + + /opt/app/sg_q7/gateway_a/config/ActingAsClient.keystore + client + + + + true + + diff --git a/ajsc-shared-config/etc/aft.properties b/ajsc-shared-config/etc/aft.properties new file mode 100644 index 0000000..1d9229c --- /dev/null +++ b/ajsc-shared-config/etc/aft.properties @@ -0,0 +1,16 @@ +#Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. +# Flow test 319 +# The DEFAULT setup for this file is for deployment to soa cloud node which will use the "bundleconfig/etc/spm2.jks" location +# For Testing Locally, you can set the system property, csiEnable=true, found within bundleconfig-local/etc/sysprops/sys-props.properties +# and switch com.att.aft.keyStore and com.att.aft.trustStore values commented out below to "ajsc-shared-config/etc/spm2.jks" + +#replace proper values for the dummy values. +com.att.aft.discovery.client.environment=TEST +com.att.aft.discovery.client.latitude=35.318900 +com.att.aft.discovery.client.longitude=-80.762200 +com.att.aft.alias=fusionbus +com.att.aft.keyStore=bundleconfig/etc/key.jks +com.att.aft.keyStorePassword=password +com.att.aft.trustStore=bundleconfig/etc/key.jks +com.att.aft.trustStorePassword=password + diff --git a/ajsc-shared-config/etc/basic-logback_root_logger_level_off.xml b/ajsc-shared-config/etc/basic-logback_root_logger_level_off.xml new file mode 100644 index 0000000..4ebe2db --- /dev/null +++ b/ajsc-shared-config/etc/basic-logback_root_logger_level_off.xml @@ -0,0 +1,87 @@ + + + + + + ERROR + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n + + + + + + + DEBUG + + ${logDirectory}/info_ajsc.log + + ${logDirectory}/info_ajsc.%i.log.zip + + 1 + 9 + + + 5MB + + + "%d [%thread] %-5level %logger{1024} - %msg%n" + + + + + ERROR + + ${logDirectory}/error_ajsc.log + + ${logDirectory}/error_ajsc.%i.log.zip + + 1 + 9 + + + 5MB + + + + "%d [%thread] %-5level %logger{1024} - %msg%n" + + + + + + INFO + + localhost + USER + + AJSC_AUDIT: [%thread] [%logger] %msg + + + + INFO + + localhost + USER + + AJSC_AUDIT: [%thread] [%logger] mdc:[%mdc] %msg + + + + + + + + + diff --git a/src/main/resources/logback.xml b/ajsc-shared-config/etc/logback.xml similarity index 86% rename from src/main/resources/logback.xml rename to ajsc-shared-config/etc/logback.xml index 48233fe..d596247 100644 --- a/src/main/resources/logback.xml +++ b/ajsc-shared-config/etc/logback.xml @@ -1,28 +1,8 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundleconfig-local/etc/appprops/AAFUserRoles.properties b/bundleconfig-local/etc/appprops/AAFUserRoles.properties new file mode 100644 index 0000000..adb7a10 --- /dev/null +++ b/bundleconfig-local/etc/appprops/AAFUserRoles.properties @@ -0,0 +1,13 @@ +#Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. + +#If using AAF for Role based authentication/authorization, define your routes/services which will utilize AAF. The AJSC will +#read this file and protect the routes given with the AAF role defined. + +#The following example would protect the JAXRS echo example service provided with the archetype. +#/services/${namespace}/v1/jaxrs-services/jaxrsExample/echo/*=com.att.ajsc.myper|mymachine|manage + +#The following example would protect ALL AJSC services running within your project. +#/**=com.att.ajsc.myperm|mymachine|manage + +#The following example would protect ALL REST services utilizing the Camel restlet routes. +#/rest/**=com.att.ajsc.myperm|mymachine|manage diff --git a/bundleconfig-local/etc/appprops/PostProcessorInterceptors.properties b/bundleconfig-local/etc/appprops/PostProcessorInterceptors.properties new file mode 100644 index 0000000..08ffefa --- /dev/null +++ b/bundleconfig-local/etc/appprops/PostProcessorInterceptors.properties @@ -0,0 +1,3 @@ +#Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. +#This properties file is for defining any PostProcessorInterceptors that have been created for your AJSC service. + diff --git a/bundleconfig-local/etc/appprops/PreProcessorInterceptors.properties b/bundleconfig-local/etc/appprops/PreProcessorInterceptors.properties new file mode 100644 index 0000000..1383071 --- /dev/null +++ b/bundleconfig-local/etc/appprops/PreProcessorInterceptors.properties @@ -0,0 +1,4 @@ +#Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. +#This properties file is for defining any PreProcessorInterceptors that have been created for your AJSC service. + +/**=com.att.ajsc.csi.restmethodmap.RestMethodMapInterceptor diff --git a/bundleconfig-local/etc/appprops/app-intercepts.properties b/bundleconfig-local/etc/appprops/app-intercepts.properties new file mode 100644 index 0000000..969ff61 --- /dev/null +++ b/bundleconfig-local/etc/appprops/app-intercepts.properties @@ -0,0 +1,8 @@ +#Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. + +#This is where all your application intercept strategies must be configured. AJSC reads this property file and adds +#the list of intercepts specified here to the camel context. This can be useful for accessing every exchange object transferred from/to +#each endpoint in the request/response flow and can allow for more precise debugging and/or processing of the exchange. + +#e.g. +#intercepts=org.openecomp.modelloader.JaxrsEchoService,packagename.class1name,packagename.class2name diff --git a/bundleconfig-local/etc/appprops/methodMapper.properties b/bundleconfig-local/etc/appprops/methodMapper.properties new file mode 100644 index 0000000..f89b7db --- /dev/null +++ b/bundleconfig-local/etc/appprops/methodMapper.properties @@ -0,0 +1,10 @@ + +{ + "helloWorld": [ + { + "method": "get", + "url": "/rest/model-loader/v1/helloWorld", + "logicalName": "GetMethod(Logical)" + } + ] +} diff --git a/bundleconfig-local/etc/sysprops/sys-props.properties b/bundleconfig-local/etc/sysprops/sys-props.properties new file mode 100644 index 0000000..39f4175 --- /dev/null +++ b/bundleconfig-local/etc/sysprops/sys-props.properties @@ -0,0 +1,115 @@ +#Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. +#This file is used for defining AJSC system properties for different configuration schemes and is necessary for the AJSC to run properly. +#The sys-props.properties file is used for running locally. The template.sys-props.properties file will be used when deployed +#to a SOA/CSI Cloud node. + +#AJSC System Properties. The following properties are required for ALL AJSC services. If you are adding System Properties for your +#particular service, please add them AFTER all AJSC related System Properties. + +#For Cadi Authorization, use value="authentication-scheme-1 +CadiAuthN=authentication-scheme-1 + +#For Basic Authorization, use value="authentication-scheme-1 +authN=authentication-scheme-2 + +#Persistence used for AJSC meta-data storage. For most environments, "file" should be used. +ajscPersistence=file + +#For Direct Invocation to be enabled (values=true/false) +directInvocationEnable=false + +# If using hawtio for local development, these properties will allow for faster server startup and usage for local development + +hawtio.authenticationEnabled=false +hawtio.config.pullOnStartup=false + +#Removes the extraneous restlet console output +org.restlet.engine.loggerFacadeClass=org.restlet.ext.slf4j.Slf4jLoggerFacade + +#server.host property to be enabled for local DME2 related testing +#server.host= + +#Enable/disable SSL (values=true/false). This property also determines which protocol to use (https if true, http otherwise), to register services into GRM through DME2. +enableSSL=false + + +#Enable/disable EJB Container +ENABLE_EJB=false + +#Enable/disable OSGI +isOSGIEnable=false + +#Generate/Skip api docs +isApiDoc=false + +#CSI related variables for CSM framework +csm.hostname=servername + + +#SOA_CLOUD_ENV is used to register your service with dme2 and can be turned off for local development (values=true/false). +SOA_CLOUD_ENV=false + +#CONTINUE_ON_LISTENER_EXCEPTION will exit the application if there is a DME2 exception at the time of registration. +CONTINUE_ON_LISTENER_EXCEPTION=false + +#Jetty Container ThreadCount Configuration Variables +AJSC_JETTY_ThreadCount_MIN=1 +AJSC_JETTY_ThreadCount_MAX=200 +AJSC_JETTY_IDLETIME_MAX=3000 + +#Camel Context level default threadPool Profile configuration +CAMEL_POOL_SIZE=10 +CAMEL_MAX_POOL_SIZE=20 +CAMEL_KEEP_ALIVE_TIME=60 +CAMEL_MAX_QUEUE_SIZE=1000 + +#GRM/DME2 System Properties +AFT_DME2_CONN_IDLE_TIMEOUTMS=5000 +AJSC_ENV=SOACLOUD + +SOACLOUD_NAMESPACE=com.att.ajsc +SOACLOUD_ENV_CONTEXT=DEV +SOACLOUD_PROTOCOL=http +SOACLOUD_ROUTE_OFFER=DEFAULT + +AFT_LATITUDE=23.4 +AFT_LONGITUDE=33.6 +AFT_ENVIRONMENT=AFTUAT + +#Restlet Component Default Properties +RESTLET_COMPONENT_CONTROLLER_DAEMON=true +RESTLET_COMPONENT_CONTROLLER_SLEEP_TIME_MS=100 +RESTLET_COMPONENT_INBOUND_BUFFER_SIZE=8192 +RESTLET_COMPONENT_MIN_THREADS=1 +RESTLET_COMPONENT_MAX_THREADS=10 +RESTLET_COMPONENT_LOW_THREADS=8 +RESTLET_COMPONENT_MAX_QUEUED=0 +RESTLET_COMPONENT_MAX_CONNECTIONS_PER_HOST=-1 +RESTLET_COMPONENT_MAX_TOTAL_CONNECTIONS=-1 +RESTLET_COMPONENT_OUTBOUND_BUFFER_SIZE=8192 +RESTLET_COMPONENT_PERSISTING_CONNECTIONS=true +RESTLET_COMPONENT_PIPELINING_CONNECTIONS=false +RESTLET_COMPONENT_THREAD_MAX_IDLE_TIME_MS=60000 +RESTLET_COMPONENT_USE_FORWARDED_HEADER=false +RESTLET_COMPONENT_REUSE_ADDRESS=true + +#Externalized jar and properties file location. In CSI environments, there are a few libs that have been externalized to aid +#in CSTEM maintenance of the versions of these libs. The most important to the AJSC is the DME2 lib. Not only is this lib necessary +#for proper registration of your AJSC service on a node, but it is also necessary for running locally as well. Another framework +#used in CSI envs is the CSM framework. These 2 framework libs are shown as "provided" dependencies within the pom.xml. These +#dependencies will be copied into the target/commonLibs folder with the normal "mvn clean package" goal of the AJSC. They will +#then be added to the classpath via AJSC_EXTERNAL_LIB_FOLDERS system property. Any files (mainly property files) that need +#to be on the classpath should be added to the AJSC_EXTERNAL_PROPERTIES_FOLDERS system property. The default scenario when +#testing your AJSC service locally will utilize the target/commonLibs directory for DME2 and CSM related artifacts and 2 +#default csm properties files will be used for local testing with anything CSM knorelated. +#NOTE: we are using maven-replacer-plugin to replace "(doubleUnderscore)basedir(doubleUnderscore)" with ${basedir} within the +#target directory for running locally. Multiple folder locations can be separated by the pipe ("|") character. +#Please, NOTE: for running locally, we are setting this system property in the antBuild/build.xml "runLocal" target and in the +#"runAjsc" profile within the pom.xml. This is to most effectively use maven variables (${basedir}, most specifically. Therefore, +#when running locally, the following 2 properties should be set within the profile(s) themselves. +#Example: target/commonLibs|target/otherLibs +#AJSC_EXTERNAL_LIB_FOLDERS=__basedir__/target/commonLibs +#AJSC_EXTERNAL_PROPERTIES_FOLDERS=__basedir__/ajsc-shared-config/etc +#End of AJSC System Properties + +#Service System Properties. Please, place any Service related System Properties below. diff --git a/pom.xml b/pom.xml index 47ed7c7..0c9da6e 100644 --- a/pom.xml +++ b/pom.xml @@ -21,26 +21,55 @@ 4.0.0 + + + ajsc-archetype-parent + com.att.ajsc + 2.0.0 + + org.openecomp.aai.model-loader model-loader 1.1.0-SNAPSHOT - war ${basedir}/target + model-loader + v1 + 2.0.0 + /appl/${project.artifactId} + /appl/${project.artifactId}/${project.version} + ${basedir}/target/swm/package/nix/dist_files${distFilesRoot} + + + 0 + 0 + + + + aaiadmin + aaiadmin + org.openecomp.aai.dev + + workstation + DEV + 1.0.0 + provided google_checks.xml 1.8 - 1.8 + 1.8 java jacoco ${project.build.directory}/surefire-reports ${project.build.directory}/coverage-reports/jacoco.exec false ${project.version} - https://nexus.onap.org + https://nexus.onap.org @@ -124,6 +153,12 @@ common-logging ${ecomp.version} + + ch.qos.logback + logback-core + 1.1.7 + + org.openecomp.sdc sdc-distribution-client @@ -190,6 +225,118 @@ + + + runAjsc + + initialize + + + org.codehaus.mojo + exec-maven-plugin + 1.3.2 + + + initialize + + java + + + false + true + java + com.att.ajsc.runner.Runner + + com.att.ajsc + ajsc-runner + + + ${basedir}/ajsc-shared-config/etc + + + + ${runAjscHome} + + + + + + AJSC_HOME + ${runAjscHome} + + + CONFIG_HOME + ${basedir}/appconfig-local/ + + + AJSC_CONF_HOME + ${basedir}/bundleconfig-local + + + logback.configurationFile + ${basedir}/ajsc-shared-config/etc/logback.xml + + + AJSC_SHARED_CONFIG + ${basedir}/ajsc-shared-config + + + + AJSC_EXTERNAL_LIB_FOLDERS + ${basedir}/target/commonLibs + + + AJSC_EXTERNAL_PROPERTIES_FOLDERS + ${basedir}/ajsc-shared-config/etc + + + AJSC_SERVICE_NAMESPACE + ${module.ajsc.namespace.name} + + + AJSC_SERVICE_VERSION + ${module.ajsc.namespace.version} + + + SOACLOUD_SERVICE_VERSION + ${project.version} + + + server.port + ${serverPort} + + + + + + context=// + port=${serverPort} + sslport=${sslport} + + + + + + java + + + + com.att.ajsc + ajsc-runner + ${ajscRuntimeVersion} + + + + + + + @@ -215,6 +362,9 @@ **/* + + ${basedir}/src/main/bin/ + @@ -321,49 +471,26 @@ - org.codehaus.mojo - license-maven-plugin - 1.10 - - false - - **.json - **.properties - - ============LICENSE_START======================================================= - ============LICENSE_END========================================================= - ================================================================================ - apache_v2 - 2017 - AT&T Intellectual Property. All rights reserved. - MODEL LOADER SERVICE - true - true - true - true - - . - - - **/*.json - - - xml - properties - xml - java - - - - - first - - update-file-header - - process-sources - - - + com.mycila + license-maven-plugin + 3.0 + +
License.txt
+ + src/main/java/** + src/test/java/** + +
+ + + + format + + process-sources + + + + org.apache.maven.plugins maven-deploy-plugin diff --git a/src/main/ajsc/model-loader_v1/model-loader/v1/conf/modelLoaderBeans.groovy b/src/main/ajsc/model-loader_v1/model-loader/v1/conf/modelLoaderBeans.groovy new file mode 100644 index 0000000..2162213 --- /dev/null +++ b/src/main/ajsc/model-loader_v1/model-loader/v1/conf/modelLoaderBeans.groovy @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * MODEL LOADER SERVICE + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +beans{ + xmlns cxf: "http://camel.apache.org/schema/cxf" + xmlns jaxrs: "http://cxf.apache.org/jaxrs" + xmlns util: "http://www.springframework.org/schema/util" + + modelLoader(org.openecomp.modelloader.service.ModelLoaderService) + + util.list(id: 'modelLoaderServices') { + ref(bean:'modelLoader') + } +} diff --git a/src/main/ajsc/model-loader_v1/model-loader/v1/docs/README.txt b/src/main/ajsc/model-loader_v1/model-loader/v1/docs/README.txt new file mode 100644 index 0000000..508361d --- /dev/null +++ b/src/main/ajsc/model-loader_v1/model-loader/v1/docs/README.txt @@ -0,0 +1,21 @@ +/*- + * ============LICENSE_START======================================================= + * MODEL LOADER SERVICE + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +Place any docs here that you want to access within the ajsc upon deployment of your service. diff --git a/src/main/ajsc/model-loader_v1/model-loader/v1/lib/README.txt b/src/main/ajsc/model-loader_v1/model-loader/v1/lib/README.txt new file mode 100644 index 0000000..f80be9b --- /dev/null +++ b/src/main/ajsc/model-loader_v1/model-loader/v1/lib/README.txt @@ -0,0 +1,21 @@ +/*- + * ============LICENSE_START======================================================= + * MODEL LOADER SERVICE + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +3rd party JAR's needed by your jars (if any) for a ajsc deployment package go here... diff --git a/src/main/docker/startup.sh b/src/main/ajsc/model-loader_v1/model-loader/v1/props/module.props similarity index 84% rename from src/main/docker/startup.sh rename to src/main/ajsc/model-loader_v1/model-loader/v1/props/module.props index c4a4d5f..aab4afa 100644 --- a/src/main/docker/startup.sh +++ b/src/main/ajsc/model-loader_v1/model-loader/v1/props/module.props @@ -1,27 +1,21 @@ -### +### # ============LICENSE_START======================================================= # MODEL LOADER SERVICE # ================================================================================ # Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. # ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and # limitations under the License. -# ============LICENSE_END========================================================= -### - -BIN_DIR=`dirname $0` - -echo "Checking environment for configuration options" -$BIN_DIR/update_config.sh - -echo "Starting up model loader..." -$BIN_DIR/jetty.sh run > /dev/null 2>&1 +# ============LICENSE_END========================================================= +### + +EXAMPLE.PROPERTY=EXAMLE_VALUE diff --git a/src/test/resources/models/vnf-model.xml b/src/main/ajsc/model-loader_v1/model-loader/v1/routes/modelLoader.route similarity index 78% rename from src/test/resources/models/vnf-model.xml rename to src/main/ajsc/model-loader_v1/model-loader/v1/routes/modelLoader.route index 2dd44b5..170c466 100644 --- a/src/test/resources/models/vnf-model.xml +++ b/src/main/ajsc/model-loader_v1/model-loader/v1/routes/modelLoader.route @@ -1,27 +1,24 @@ - - - - model-id - widget - generic-vnf - v1.0 - model-vid - + ============LICENSE_END========================================================= + --> + + + + + diff --git a/src/main/assemble/ajsc_module_assembly.xml b/src/main/assemble/ajsc_module_assembly.xml new file mode 100644 index 0000000..520870f --- /dev/null +++ b/src/main/assemble/ajsc_module_assembly.xml @@ -0,0 +1,86 @@ + + + + ${version} + false + + zip + + + + ${project.basedir}/target/versioned-ajsc/routes/ + ${module.ajsc.namespace.name}/${module.ajsc.namespace.version}/routes/ + + *.route + + + + + + ${project.basedir}/target/versioned-ajsc/docs/ + ${module.ajsc.namespace.name}/${module.ajsc.namespace.version}/docs/ + + *.* + + + + + + + ${project.basedir}/target/versioned-ajsc/lib/ + ${module.ajsc.namespace.name}/${module.ajsc.namespace.version}/lib/ + + *.jar + + + + + ${project.basedir}/target/versioned-ajsc/extJars/ + ${module.ajsc.namespace.name}/${module.ajsc.namespace.version}/extJars/ + + *.jar + + + + + + ${project.basedir}/target/ + ${module.ajsc.namespace.name}/${module.ajsc.namespace.version}/lib/ + + *.jar + + + + + ${project.basedir}/target/versioned-ajsc/conf/ + ${module.ajsc.namespace.name}/${module.ajsc.namespace.version}/conf/ + + *.* + + + + + + + diff --git a/src/main/webapp/WEB-INF/rest-servlet.xml b/src/main/assemble/ajsc_props_assembly.xml similarity index 56% rename from src/main/webapp/WEB-INF/rest-servlet.xml rename to src/main/assemble/ajsc_props_assembly.xml index 6a23c2b..e26497b 100644 --- a/src/main/webapp/WEB-INF/rest-servlet.xml +++ b/src/main/assemble/ajsc_props_assembly.xml @@ -1,32 +1,43 @@ - - - - - - - - + ============LICENSE_END========================================================= + --> + + + ${version}_properties + false + + zip + + + + ${project.basedir}/target/versioned-ajsc/props + ${module.ajsc.namespace.name}/${module.ajsc.namespace.version}/props/ + + *.props + + + + + + + + diff --git a/src/main/assemble/ajsc_runtime_assembly.xml b/src/main/assemble/ajsc_runtime_assembly.xml new file mode 100644 index 0000000..c5c515a --- /dev/null +++ b/src/main/assemble/ajsc_runtime_assembly.xml @@ -0,0 +1,64 @@ + + + + runtimeEnvironment + false + + zip + + + + ${project.basedir}/target/versioned-runtime/context/ + runtime/context/ + + *.context + + + + ${project.basedir}/target/versioned-runtime/serviceProperties/ + runtime/serviceProperties/ + + *.props + + + ${project.basedir}/target/versioned-runtime/shiroRole + runtime/shiroRole/ + + *.json + + + ${project.basedir}/target/versioned-runtime/shiroUser + runtime/shiroUser/ + + *.json + + + ${project.basedir}/target/versioned-runtime/shiroUserRole + runtime/shiroUserRole + + *.json + + + + diff --git a/src/main/resources/model-loader.properties b/src/main/bin/start.sh similarity index 51% rename from src/main/resources/model-loader.properties rename to src/main/bin/start.sh index 7b8f63d..07f707e 100644 --- a/src/main/resources/model-loader.properties +++ b/src/main/bin/start.sh @@ -1,43 +1,45 @@ -### +### # ============LICENSE_START======================================================= # MODEL LOADER SERVICE # ================================================================================ # Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. # ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and # limitations under the License. -# ============LICENSE_END========================================================= -### - -# Model Loader Distribution Client Configuration -ml.distribution.ACTIVE_SERVER_TLS_AUTH=false -ml.distribution.ASDC_ADDRESS= -ml.distribution.CONSUMER_GROUP=aai-ml-group -ml.distribution.CONSUMER_ID=aai-ml -ml.distribution.ENVIRONMENT_NAME= -ml.distribution.KEYSTORE_PASSWORD= -ml.distribution.KEYSTORE_FILE=asdc-client.jks -ml.distribution.PASSWORD= -ml.distribution.POLLING_INTERVAL=30 -ml.distribution.POLLING_TIMEOUT=20 -ml.distribution.USER=ci -ml.distribution.ARTIFACT_TYPES=MODEL_INVENTORY_PROFILE,MODEL_QUERY_SPEC,VNF_CATALOG - -# Model Loader AAI REST Client Configuration -ml.aai.BASE_URL= -ml.aai.MODEL_URL=/aai/v8/service-design-and-creation/models/model/ -ml.aai.NAMED_QUERY_URL=/aai/v8/service-design-and-creation/named-queries/named-query/ -ml.aai.VNF_IMAGE_URL=/aai/v8/service-design-and-creation/vnf-images -ml.aai.KEYSTORE_FILE=aai-os-cert.p12 -ml.aai.KEYSTORE_PASSWORD= -ml.aai.AUTH_USER=ModelLoader -ml.aai.AUTH_PASSWORD= +# ============LICENSE_END========================================================= +### + +#!/bin/sh + +BASEDIR="/opt/app/model-loader/" +AJSC_HOME="$BASEDIR" + +if [ -z "$CONFIG_HOME" ]; then + echo "CONFIG_HOME must be set in order to start up process" + exit 1 +fi + +CLASSPATH="$AJSC_HOME/lib/*" +CLASSPATH="$CLASSPATH:$AJSC_HOME/extJars/" +CLASSPATH="$CLASSPATH:$AJSC_HOME/etc/" +PROPS="-DAJSC_HOME=$AJSC_HOME" +PROPS="$PROPS -DAJSC_CONF_HOME=$BASEDIR/bundleconfig/" +PROPS="$PROPS -Dlogback.configurationFile=$BASEDIR/bundleconfig/etc/logback.xml" +PROPS="$PROPS -DAJSC_SHARED_CONFIG=$AJSC_CONF_HOME" +PROPS="$PROPS -DAJSC_SERVICE_NAMESPACE=model-loader" +PROPS="$PROPS -DAJSC_SERVICE_VERSION=v1" +PROPS="$PROPS -Dserver.port=8080" +PROPS="$PROPS -DCONFIG_HOME=$CONFIG_HOME" + +echo $CLASSPATH + +java -Xms1024m -Xmx4096m -XX:PermSize=2024m $PROPS -classpath $CLASSPATH com.att.ajsc.runner.Runner context=// sslport=8081 diff --git a/src/main/config/ajsc-chef.jks b/src/main/config/ajsc-chef.jks new file mode 100644 index 0000000000000000000000000000000000000000..aeca7700182fb1824b47fca285204122a879ff85 GIT binary patch literal 5256 zcmdT|TTfiq6`ngV%y1iS1_lfU6TrY31_rRX8e?;}F&GS(`*qA^xC~%0mo#-FS52M9 zY8BOaNKz%P)yh$$Hfs7%MXFs@Y2qf0V<&aeSgl|B(&jJp`(|wh?6@zL`cUax-&$** zea_iut+m&gGhe^=+pl+^)9DOBF`pmz``2_j{V5!u90TdhXA4TSa-GfyM}zEW18hT> z?(;XHn;}k!X17|xa$z(;0J~MMH=A`l4RD2PVHV>Vlf_{;)3M`(+6>*bt|%>nM?!2N z9pl4(|IGN#h}~)n>G3Vs`4;D04lSCK!fkfz$@%fcVZYZmx8!na$s9G>V%KND%Qni#PmlURtk6iOD*Nk5no}Hf==QJ%f!ESYxXr-Pv=r#gf$Zrc1DVj=h{cAdfc$)Azct4QdA|> z667KzF%HxU$(U>be|8PD3;~u-*Ye!GuyxnktqzQ258b+&+IF!I=7z8I;SYn8;@yj4 zZ$T}0Z~?%asU_(GbO~f!hPH8`V`A>*h2BbJSZrP4R?as^gCh@r2Gb>O4W9-W z5;Zji{qQZW7Z`;kFed4c-+vo)?{!egC(nWf7TpSrf}juM%Ns>u;-6X-oe_To#&L1L zom~3ZWYGV|tM9-Lh3w9Ovn~_3ty&K<2|#;IYjlqX#>X#k{{f{CyLA?Pqz>eR#6tjs zQLocKtu(MZxuK;P;&|3YMjZI`b@k}t?goBCWoRq`M@ly2@Gul>g{d;ObWF(T$~1Ht zWQucJxu7qus$*3(XW;_%_4nUBw%vVLJn%p!XsQf%zNRK|R9RPvSDX(Wxw0Uhsj)pm zo2`Mvuoo`w<8#{N*mh$v48}q|;~$>qM8F9N=b+wm_qq&$y`%fV)g&+PfBTZ%nhJdi z!pS;_S|2QKmzknarsv`a=-9g5IsjeK5X0LFs{a0?@4!N5*XvBf=a)uRQ*WsVjG7H> zXeJ0cuictw(VO(ShG?{F9S12o<`ekx`9nNsR6KBP2B>&{8Z#8d(!Kvi!3xt*?FH4V zlDhzVi9Q6lbJfU^MhH(2;ux%0hzfNei*Sbq1{ca?5=(1kXaB$+Pm=KqjQfxQR2v~9 z!l$9)RzRKN2P%a{_m`Jt0L(j%L0Tc@8$)2=tLH##Jzd~5894`417UsaMK?E!fawBw zug*We!h~@#8F8SatQ(%XJqJ2Iv1+v4y#!0`-vclO1)|E{|CJcrECBnGUQBRPFJq^V zHXMbcWcpY?8@mIYzKaCJ#eP*e}7cg$|RbA5Iylab@Jw25>uYbVFV z6+eOYBe!l~$jzRfzWm^d9PUOR-aE0`4^OKubI+d6gO$oq4}JI&I5C{d13vlgAu+&h z6D%1Zc2Sj7GMutG6$Cj3=5DPGdN7!2$HvaRyI7(l5XM$e4#f}%hNjoYSdWX7k6!#~ za8!&+QCrQcV(dP9Om+z$2Z)BS?$dP!W;FzoVd3Qq^$eYXQCo)qTcU)c>pP8N{pshQ z{sdN^cx+k%J~pph4e6fofcHV{*4pw6&nB!`2$1L>;f2ma{`U3_hE~Ax&r1Pu8L`_( zIyRtrP2Ry$rfwH|pr5&&ZafSI9$O=PUOLB>nq$c>X@gmD_XWp+;r1Muxsa&D<6z}L z@t)izY-v-FgjOAzj#?;uhiaHG)k1f-3?B{%B(B?THCMrjkTGy{{sK6OYhWfD&6Z6l zK&`tKrcFk`oW`6*wg-n`I3a!f33KPFT2kX$B|AyQVs|u@fFS~Mv>2An6Zqol`liMG z;Mx|0IsdyWO!WPiO7_n3iKB5vz4=`1p_Ss`gq&O7Q&q&mWom$BNRgNc2cQcX+hGW! z>t{f{3nQ!N^h32-5pXgf*$`!}#SJ=P_Hb(hTW&5V%NHfCFlz|lHQD#f;;I~|6?5;M zfV9X#cNAZO|9ay$;HgQ_Ql3h-9N)_-oVS0$qzN+WI>lIrQn`htW^S?N11EUHvX zDw8H)g{m~D`Y>#UVNB1B$~JK4t&nX_5=`8Cm9Lc;9tl}<&&p`nD&HAgkO9)?`S`U~ z?h&^02RHk{oW6As6a*tM$_V#-aLMVH;igBIpJSE*_FH!SK+}S58IO%GaXxzYW!S(r zUtvswZZJ^9gM;in8^zoV=OE>fowk(Dbr~;$_Co~RtH9~9fdkXio8qu47)P!w%bDwH zIVs~Ej@@WAVrXAyFE3UJ$v2gPCm_iuPw~DnmJV+xqZPsDsP=J*Mz)i#p1dxHJ0!5C zq4hzGFxv0GR{+j5Po+Zfj6Hc|D_^|i3?1JxDG0K{J?b>Ydc$9cB>Xn7augH+NO@W z;6S+YW3;HiN3A1l#y2`VGv!D;P-YFDt5ndzagZrWJyDa_yC0EoYKRfl+nTaq254iW?hhNtHa4jeRb{{j1Y*k(Nl3jT;tsfN`bwtf3s>fHi2JPKs%>jU%rR=xnsS!3SRdp8%MyLjjv zo7C}27JKDmZys(F;L-Q5gA;f%(8KfHi6Fiexl{Wgz)q9c=Y&(K`dp!xcM!B4cKq|& z<>3^sxaS+8xmML?xiQk@5SSNLJIT+t9Jlo|5YCu%fEeLLZ;H>B?OCwIzya7kfWKY= zv7esUX8gL<2vfW%mYL$B1l*BorN`MS*!Kzx zHvhwZG2*Cvb~b(XChVLwP%?zi!lg5BfO*r==I609;xoknV{8n!%&C|koZ;8SUa)Bc zx%0un1~<%NapOMtadYrMX*|rn5m35{kNWgj?P7Gk3AWQG;0Z)L@K*-=pK3vb>M= zT@?7S4kI;Zggswif%3Bk^Vf%$a%=st?!4`rV!o>m^Jjx#6RH=&Tc1s-IO$x6!5tys uGt~9-5rg<6yY}vk>bcLavBuIN+c|MEZ6uak28dCGC0;vJ=$Z7;@P7m3`PLW! literal 0 HcmV?d00001 diff --git a/src/main/config/ajsc-jetty.xml b/src/main/config/ajsc-jetty.xml new file mode 100644 index 0000000..43741bd --- /dev/null +++ b/src/main/config/ajsc-jetty.xml @@ -0,0 +1,90 @@ + + + + + + + + + true + + + /etc/runner-web.xml + /etc/ajsc-override-web.xml + true + + + false + + + /extJars/httpclient-4.5.jar,/extJars/httpcore-4.4.1.jar,/extJars/json-20131018.jar + + + + + + + + + + + + + + + + + + + + + + + + /extApps + 10 + true + + + + + + + + + + + + + + + + + + + + + + + false + + + diff --git a/src/main/config/ajsc-override-web.xml b/src/main/config/ajsc-override-web.xml new file mode 100644 index 0000000..b0d44f3 --- /dev/null +++ b/src/main/config/ajsc-override-web.xml @@ -0,0 +1,73 @@ + + + + + + + + InterceptorFilter + /services/* + + + InterceptorFilter + /rest/* + + + + springSecurityFilterChain + /* + + + + ManagementServlet + /mgmt + + + + RestletServlet + /rest/* + + + + CamelServlet + /services/* + + + + jsp + *.jsp + *.jspf + *.jspx + *.xsp + *.JSP + *.JSPF + *.JSPX + *.XSP + + + default + /* + + diff --git a/src/main/config/ajscJetty.jks b/src/main/config/ajscJetty.jks new file mode 100644 index 0000000000000000000000000000000000000000..48cdbff4a8344b9bfa164b340c2fd3b4f7020c41 GIT binary patch literal 3736 zcmcIm`)`xy75+Zo;@EM*>Rd47o-~jPU}JKFn8b+*gxq6897y6^aPAj^NkW*tv>V%4 zyRF*Rc3M>xRjX8OrCU)iVyiZ!iWb^R6&;0+l1^fqRQ0F+3ws`)k1rMKualnhoO9my z^Y^~zyyrcizq$6eZyrKX6az#}iZwQUHo7o6AH_gG9_fKn6tm)nHbLC!7Kg3UqMFnS z!}nCxtZ~`P?CJNqmyXXx;aI2o792JhsgV548_!HZo2o&;_RpUv+ae~{GJf#q z!MdVh8R!xP4nfL{AQh4e5$xF~Iy}(66IPBsk$|-o5>E$Jn_VvLL1hkp0YpcwRi{JyRN4$I;F!}LQV-;fNJSJM_^pU+{Hynlzw2I@?=fy~jM<2ZK zYMg0YqvWj1I5XlGbA?L-Ou3FzW4(#FkNygOh_9TL3HA6+f68Y+hvRAh<;y5IQ>>7;EBd2S36TyJ}*wf9SB8?IRywf@kmB1)ixQLB5S$xjotN$7L)J zY8rA<+=HTYjwS9ruRHay3dFnnV`w8U64wb&uw;1R4}SN?zux3CtbXF@=fJ1(vcPqa z_;C=W8**~&SZ(DbJ;vQh0!~1fkCxM*20JtK!~~P zR{D;@%HsVhs$l7rP4gheg3(ed51PvZU835#YjL;8Y6yLur?!wkF7(58= z{_wy9!|lv~Yb65KL5G*4!sl1`j#<{vynA=Dxxo}@XUgDs8^-y1;PZ>^>`2=oGpxsM z2GiPBzwF|X@l=7rGcn#Ko?H3xV&1d1yKjJX)MhedfLR54xlO^@Vl$I}M!YN@Hoy`F z&O^9;mi{QqOxq>PdI;iy2;O@(8P1lLn{PU7EQ>&diCc!Szq%nhjAEU?{x0i*DFGG_ zBwui@T^nL}jqFcA#luwbKD$dcvm2KAIjA6Hh*Wq+d!vg*dnOIU1+`nh1Ev-nEWshD zi5~U)`}$zaSO!*ZKO2KJEVJOyHqd7mbf1X^_-gG7!Cg->P+uJziVp&?-E4Lh<7T!7 zTE}J!G3iMS#Mh=Cm#6bZ33u}nENn))zae|$7Y0^_fWIzbL1=Zmv8VAl3l40L&%-|CqzOtKIdAVhpm_jooBJElq=JFqjV2 z@v^!dHcKjlJput7HdVFb4^r4;cc)s6$4nNd;aKpYV|5x1`#oFmw+S;T&J=&B!`~J1 zd(!wC3^{C0qdye#IBae^eY?}t66^`+zR_v&9}Tv+^K%?F&px-;Q|GDn)>rR6A%2ag zM)UvA>myLL_`5>KUqGIVnvwjAs5)#0da42jPVN}&GM8>V0n=eCVQmHPzHDbtnq_eS zY;}k4yai^<2~zGq11`A3Is1@?xi+=$Na&vRSReQzet(b+d zr~LDZ!Kf+>uE<^B&O>qLrJJ%%nLH*zBM;=?KfN03=Z$6e5*Ty8t59%9l7*rw+jfN9 zmUJH;wrc^yteUGYfy#ueLwXT!ls`fcz3j_XfRey^6e+2yW?*8^z2Ar=h zvnn&#vUrn^L71LVrlOQ*|PW9frj&V8Ix8l3)CaF^zwDO~%1DUQGTe;RWhYSm*+l zN8zI>VTe_hLe2roM}OkE1N=7kiK%mgZoy#NyZwrcFj+i==)HHg$Ow3=w%0FS8TAIV d$UppJT1E%vmLWa}Z$I0*0!fDe1J|Dh{|_E2uSEa= literal 0 HcmV?d00001 diff --git a/src/main/config/cadi.properties b/src/main/config/cadi.properties new file mode 100644 index 0000000..c3b8b14 --- /dev/null +++ b/src/main/config/cadi.properties @@ -0,0 +1,56 @@ +### +# ============LICENSE_START======================================================= +# MODEL LOADER SERVICE +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR 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 properties file is used for defining AAF properties related to the CADI framework. This file is used for running AAF framework + +#In order to test functionality of cadi-ajsc-plugin locally cross domain cookie. Cadi "should" find your hostname for you. +#However, we have seen some situations where this fails. A Local testing +#modification can include modifying your hosts file so that you can use "mywebserver.att.com" for your localhost in order +#to test/verify GLO functionality locally. If you are on a Windows machine, you will already have a machine name associated with +#it that will utilize an AT&T domain such as "sbc.com". You may need to add your domain to this as a comma separated list depending +#upon your particular machine domain. This property is commented out as cadi SHOULD find your machine name. With version 1.2.1 of cadi, +#it appears to resolve Mac machine names as well, now. But, this can be somewhat inconsistent depending on your specific working envrironment. +hostname=mywebserver.att.com + +#Setting csp_domain to PROD will allow for testing using your attuid and password through GLO. +csp_domain=PROD +csp_devl_localhost=true + +basic_realm=csp.att.com +#basic_realm=aaf.att.com +basic_warn=TRUE + +cadi_loglevel=WARN +cadi_keyfile=target/swm/package/nix/dist_files/appl/model-loader/etc/keyfile + +# Configure AAF +#These are dummy values add appropriate values required +aaf_url=url + +#AJSC - MECHID +#These are dummy values add appropriate values required +aaf_id=dummyid@ajsc.att.com +aaf_password=enc:277edqJCjT0RlUI3BtbDQa-3Ha-CQGd +aaf_timeout=5000 +aaf_clean_interval=30000 +aaf_user_expires=5000 +aaf_high_count=1000 + + diff --git a/src/main/config/jul-redirect.properties b/src/main/config/jul-redirect.properties new file mode 100644 index 0000000..b94397e --- /dev/null +++ b/src/main/config/jul-redirect.properties @@ -0,0 +1,32 @@ +### +# ============LICENSE_START======================================================= +# MODEL LOADER SERVICE +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +# Bridge JUL->slf4j Logging Configuration File +# +# This file bridges the JUL logging infrastructure into +# SLF4J so JUL logs go to logback implementation provided +# in this project. SLF4J also captures log4j and has +# other framework options as well providing a common +# logging infrastructure for capturing all logs from different +# libraries using different frameworks in one place. + +# Global properties +handlers=org.slf4j.bridge.SLF4JBridgeHandler +.level= ALL diff --git a/src/main/config/keyfile b/src/main/config/keyfile new file mode 100644 index 0000000..882e86a --- /dev/null +++ b/src/main/config/keyfile @@ -0,0 +1,27 @@ +ZuIwp0TkyVPDeX1Up-8JtkMWvjsCpoiu1_VKeWrtrvxunvAke8_tiFyHPPyb2nkhepFYj6tXzpfS +rGz5XF_TH9NbsKaP8u0HV5clz2WriYQRvHS85vjY7hXxkpFuLb7zkLAPqTyIDpj7FiW61NzsRUAq +TM8jH16jr7mBNnb56w24mNGOwznMPcIZKcjgZU1ekaPDFpWyhQElU7Y0q_94P_Gkk45r66Hj22sU +OiOaaftmudZlswLw8-8Zaakqf2yW9HjMVfuYCwSodBHCW5rdB3Ctb5W36rnD_AQco3Ky2PgPmqvk +QkJYuUHpbuDqVHqLOajlKSIGMTIqAIBg51fRaaONtD-Q5xzY8E5wO1YWTLKcP5tsNvUpzM8Wu3NS +ynpGpUcvlTqWWsGzTbzOyamyKkdNdx97sSqjM25Zh1-ps48h6cddGYWpab7SUvqRCS11QBUyLTry +2iwTEHMhHRIbo7PO99ALQfuq9gI1zKGfurJdvLBeBaFs5SCF0AiCZ3WcDO8Rv3HpxVZ2_ShbDxb0 +eMoO6SotXu51fj8Y3-WqsfZziQyEsHyqpg5uQ6yUtz01h5YHLEoVuotF1U4agmQR6kEkYk-wNOiZ +v-8gaA9gtbLoAdKhuKFxQgQLNMf6GzVzZNujbmDzLoZAP_mXAv29aBPaf64Ugzv-Oa5GZdBgD-Xd +_pahML-ionw99r0TnkpShYmDqMKhMdjaP3m87WIAZkIB-L-VTyKcEsJ4340VSzCOsv3waiM0S89u +4cMcG5y-PLY8IoipIlLUPTWD3SjcQ9DV1Dt3T5KjdWLsj48D3W4K4e9PB8yxs0gtUjgVUR2_xEir +G5eDO9Ac1eHFWGDFFP0SgG-TbHJUKlvy9mwLzmU0fC3xPjhqmIr-v0HxF7HN-tmb1LHDorno8tSN +u7kUGcKSchIiFfvkd066crUb2mH7PnXTaWmAjyVj9VsBExFUYEdpHMAV4sAP9-RxZGDRt46UhrDK +QZvvNhBVyOEjHPHWI4vl1r1v8HNH1_2jZu5DVJWyHWR56aCo1lhFH9_X6UAHUHbnXViDONZOVXlT +9-WD0tk2zJGuwrhdZDAnPnAmjfwbwbpnr5Hmex1i1JiD7WVyP1kbfoej2TmdiYbxr9oBYaGQ29JI +aHod7MQCLtvL1z5XgnDPLZ4y3_9SbqHKYbNa8UgZkTLF5EacGThYVFDLA9cbafHDtR1kMGE3vv4D +EJ-0pAYTOGmKlVI7DwNyKsY9JTyudrxTqhOxi9jgcJNWiUaNe9yhL8Pyc2YBqUTTYhh_a2d1rvkZ +0Gh1crviVxqBrIkRKaMRXZ4f1vDLz-3NvG_vwPOo8WRFo5nGmSdTw7CjBaigJ_cYCfDhoP11pEnw +cndsZNcHs-v05LlxeIIMDD_f5Bvz-il_DLA4eK2HqgLdxh8ziSDl2azk14MJY4amzz6reEXUuKLV +RsZGf_jbDGKhE2HuDQ5ovoLOi4OqE1oRuqh-dGxitrYouP2SN1l_1tCEMRth86FMV-6AQtZsvdUo +y9MtQ7e35atjA8nHtgADlDTmJBKQiUHUsOZ77p1qp17HAFMovUkc739opfEYnKUn6Itpw5Ipm_Is +ra6chJUfMpOFof5rb5OjqFAN27c_-mPo1lQU3ndYlKGh_n5V8ufX6v2Yri8WzOPf6hjVYotkmoMP +NPAICDCB8W5ddBjsopzLVVEtaXDu9Qj6-zf77hT4iQ7rBd2Ner8iLqN3Kis0dvkNM3_uH8onau1G +Y_YYw7PPSZyd2S_7Dd6G-IG4ayO6e5DD6oUwwekyiQI_3rTXNa_wldGxqW9u818010ekE4Qdlfcj +beIn7fAeaOjReZ87hRgWyMs-EgTVHw8RL3yI_O6VvRTVRONRF1Y4C_-IYa8z-bfrwXx3BBd9TTgb +EnS9wVOyC2OgUN6BhPLGLhxzkJ05nEjizXEc9t5EPYoSRwesajGGrrG_0-qWbuU5hKLPLkyeJLHb +5HXOTVsrUR59Vov2M3_EswkxcImblox3k3VS2yihZMGyfqLzZIUXgd8ufkevKKU6DxwacGTb \ No newline at end of file diff --git a/src/main/config/runner-web.xml b/src/main/config/runner-web.xml new file mode 100644 index 0000000..99d9191 --- /dev/null +++ b/src/main/config/runner-web.xml @@ -0,0 +1,117 @@ + + + + + + + + contextConfigLocation + /WEB-INF/spring-servlet.xml, + classpath:applicationContext.xml + + + + + spring.profiles.default + nooauth + + + + org.springframework.web.context.ContextLoaderListener + + + + ManagementServlet + ajsc.ManagementServlet + + + + + InterceptorFilter + ajsc.filters.InterceptorFilter + + preProcessor_interceptor_config_file + /etc/PreProcessorInterceptors.properties + + + postProcessor_interceptor_config_file + /etc/PostProcessorInterceptors.properties + + + + + + RestletServlet + ajsc.restlet.RestletSpringServlet + + org.restlet.component + restletComponent + + + + + CamelServlet + ajsc.servlet.AjscCamelServlet + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + + spring + org.springframework.web.servlet.DispatcherServlet + 1 + + + + + + + + jsp + org.apache.jasper.servlet.JspServlet + + + + + + + + + default + org.eclipse.jetty.servlet.DefaultServlet + + dirAllowed + true + + + + diff --git a/src/main/docker/.dockerignore b/src/main/docker/.dockerignore deleted file mode 100644 index 1128374..0000000 --- a/src/main/docker/.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -*.war -*.jsonld \ No newline at end of file diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile index 99c34fd..6f187d5 100644 --- a/src/main/docker/Dockerfile +++ b/src/main/docker/Dockerfile @@ -1,53 +1,24 @@ -### -# ============LICENSE_START======================================================= -# MODEL LOADER SERVICE -# ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -### - FROM ubuntu:14.04 -ARG jettyrel=9.3.9.v20160517 -ARG jettydist=jetty-distribution-${jettyrel} -ARG jettybase=/opt/jetty - -RUN apt-get update && apt-get --force-yes -y -f install wget - -# Install java8 -RUN apt-get install -y software-properties-common -# sudo -E is required to preserve the environment -# If you remove that line, it will most like freeze at this step +ARG MICRO_HOME=/opt/app/model-loader +ARG BIN_HOME=$MICRO_HOME/bin -RUN apt-get install --reinstall ca-certificates && \ - sudo -E add-apt-repository ppa:openjdk-r/ppa && apt-get update && apt-get install -y openjdk-8-jdk - -# Setup JAVA_HOME, this is useful for docker commandline +RUN apt-get update +# Install and setup java8 +RUN apt-get update && apt-get install -y software-properties-common +## sudo -E is required to preserve the environment. If you remove that line, it will most like freeze at this step +RUN sudo -E add-apt-repository ppa:openjdk-r/ppa && apt-get update && apt-get install -y openjdk-8-jdk +## Setup JAVA_HOME, this is useful for docker commandline ENV JAVA_HOME usr/lib/jvm/java-8-openjdk-amd64 RUN export JAVA_HOME -RUN wget http://central.maven.org/maven2/org/eclipse/jetty/jetty-distribution/${jettyrel}/${jettydist}.tar.gz -RUN gunzip ${jettydist}.tar.gz && tar xvf ${jettydist}.tar - -COPY model-loader* $jettydist/webapps/model-loader/ - -COPY startup.sh update_config.sh ${jettydist}/bin/ -RUN chmod 700 ${jettydist}/bin/startup.sh && chmod 700 ${jettydist}/bin/update_config.sh -RUN mkdir -p ${jettybase} -RUN mv ${jettydist} ${jettybase}/${jettydist} -RUN rm -rf $jettybase/$jettydist/demo-base +# Build up the deployment folder structure +RUN mkdir -p $MICRO_HOME +ADD swm/package/nix/dist_files/appl/model-loader/* $MICRO_HOME/ +RUN mkdir -p $BIN_HOME +COPY *.sh $BIN_HOME +RUN chmod 755 $BIN_HOME/* +RUN ln -s /logs $MICRO_HOME/logs -CMD /opt/jetty/*/bin/startup.sh +CMD /opt/app/model-loader/bin/start.sh diff --git a/src/main/docker/update_config.sh b/src/main/docker/update_config.sh deleted file mode 100644 index 77916ed..0000000 --- a/src/main/docker/update_config.sh +++ /dev/null @@ -1,151 +0,0 @@ -#!/bin/bash - -### -# ============LICENSE_START======================================================= -# MODEL LOADER SERVICE -# ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR 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 script will update the config file, with config values supplied -# through environment variables, if set -# - -CONFIG_FILE=`dirname $0`/../webapps/model-loader/WEB-INF/classes/model-loader.properties - -# Distribution client configuration -ENVVAR=DISTR_CLIENT_ACTIVE_SERVER_TLS_AUTH -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.distribution.ACTIVE_SERVER_TLS_AUTH/s/.*/ml.distribution.ACTIVE_SERVER_TLS_AUTH=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=DISTR_CLIENT_ASDC_ADDRESS -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.distribution.ASDC_ADDRESS/s/.*/ml.distribution.ASDC_ADDRESS=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=DISTR_CLIENT_CONSUMER_GROUP -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.distribution.CONSUMER_GROUP/s/.*/ml.distribution.CONSUMER_GROUP=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=DISTR_CLIENT_CONSUMER_ID -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.distribution.CONSUMER_ID/s/.*/ml.distribution.CONSUMER_ID=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=DISTR_CLIENT_ENVIRONMENT_NAME -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.distribution.ENVIRONMENT_NAME/s/.*/ml.distribution.ENVIRONMENT_NAME=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=DISTR_CLIENT_KEYSTORE_PASSWORD -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.distribution.KEYSTORE_PASSWORD/s/.*/ml.distribution.KEYSTORE_PASSWORD=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=DISTR_CLIENT_KEYSTORE_FILE -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.distribution.KEYSTORE_FILE/s/.*/ml.distribution.KEYSTORE_FILE=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=DISTR_CLIENT_PASSWORD -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.distribution.PASSWORD/s/.*/ml.distribution.PASSWORD=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=DISTR_CLIENT_POLLING_INTERVAL -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.distribution.POLLING_INTERVAL/s/.*/ml.distribution.POLLING_INTERVAL=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=DISTR_CLIENT_POLLING_TIMEOUT -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.distribution.POLLING_TIMEOUT/s/.*/ml.distribution.POLLING_TIMEOUT=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=DISTR_CLIENT_USER -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.distribution.USER/s/.*/ml.distribution.USER=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=DISTR_CLIENT_ARTIFACT_TYPES -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.distribution.ARTIFACT_TYPES/s/.*/ml.distribution.ARTIFACT_TYPES=$ENVVALUE/" $CONFIG_FILE; - - -# Model Loader Application Server REST Client Configuration -ENVVAR=APP_SERVER_BASE_URL -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.aai.BASE_URL/s/.*/ml.aai.BASE_URL=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=APP_SERVER_MODEL_URL -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.aai.MODEL_URL/s/.*/ml.aai.MODEL_URL=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=APP_SERVER_NAMED_QUERY_URL -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.aai.NAMED_QUERY_URL/s/.*/ml.aai.NAMED_QUERY_URL=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=APP_SERVER_VNF_IMAGE_URL -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.aai.VNF_IMAGE_URL/s/.*/ml.aai.VNF_IMAGE_URL=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=APP_SERVER_KEYSTORE_FILE -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.aai.KEYSTORE_FILE/s/.*/ml.aai.KEYSTORE_FILE=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=APP_SERVER_KEYSTORE_PASSWORD -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.aai.KEYSTORE_PASSWORD/s/.*/ml.aai.KEYSTORE_PASSWORD=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=APP_SERVER_AUTH_USER -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.aai.AUTH_USER/s/.*/ml.aai.AUTH_USER=$ENVVALUE/" $CONFIG_FILE; - -ENVVAR=APP_SERVER_AUTH_PASSWORD -ENVVALUE=${!ENVVAR} -ENVVALUE=${ENVVALUE//\//\\/} -[ -z ${!ENVVAR+x} ] \ - || sed -i "/ml.aai.AUTH_PASSWORD/s/.*/ml.aai.AUTH_PASSWORD=$ENVVALUE/" $CONFIG_FILE; diff --git a/src/main/java/org/openecomp/modelloader/config/ModelLoaderConfig.java b/src/main/java/org/openecomp/modelloader/config/ModelLoaderConfig.java index 26f13ad..407b015 100644 --- a/src/main/java/org/openecomp/modelloader/config/ModelLoaderConfig.java +++ b/src/main/java/org/openecomp/modelloader/config/ModelLoaderConfig.java @@ -1,235 +1,232 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.config; - -import org.eclipse.jetty.util.security.Password; -import org.openecomp.sdc.api.consumer.IConfiguration; - -import java.io.File; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -public class ModelLoaderConfig implements IConfiguration { - - // Configuration file structure - public static final String PREFIX_MODEL_LOADER_CONFIG = "ml"; - public static final String PREFIX_DISTRIBUTION_CLIENT = - PREFIX_MODEL_LOADER_CONFIG + ".distribution."; - public static final String PREFIX_AAI = PREFIX_MODEL_LOADER_CONFIG + ".aai."; - public static final String PREFIX_DEBUG = PREFIX_MODEL_LOADER_CONFIG + ".debug."; - - // Configuration file properties - protected static final String PROP_ML_DISTRIBUTION_ACTIVE_SERVER_TLS_AUTH = - PREFIX_DISTRIBUTION_CLIENT + "ACTIVE_SERVER_TLS_AUTH"; - protected static final String PROP_ML_DISTRIBUTION_ASDC_ADDRESS = PREFIX_DISTRIBUTION_CLIENT - + "ASDC_ADDRESS"; - protected static final String PROP_ML_DISTRIBUTION_CONSUMER_GROUP = PREFIX_DISTRIBUTION_CLIENT - + "CONSUMER_GROUP"; - protected static final String PROP_ML_DISTRIBUTION_CONSUMER_ID = PREFIX_DISTRIBUTION_CLIENT - + "CONSUMER_ID"; - protected static final String PROP_ML_DISTRIBUTION_ENVIRONMENT_NAME = PREFIX_DISTRIBUTION_CLIENT - + "ENVIRONMENT_NAME"; - protected static final String PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD = PREFIX_DISTRIBUTION_CLIENT - + "KEYSTORE_PASSWORD"; - protected static final String PROP_ML_DISTRIBUTION_KEYSTORE_FILE = PREFIX_DISTRIBUTION_CLIENT - + "KEYSTORE_FILE"; - protected static final String PROP_ML_DISTRIBUTION_PASSWORD = PREFIX_DISTRIBUTION_CLIENT - + "PASSWORD"; - protected static final String PROP_ML_DISTRIBUTION_POLLING_INTERVAL = PREFIX_DISTRIBUTION_CLIENT - + "POLLING_INTERVAL"; - protected static final String PROP_ML_DISTRIBUTION_POLLING_TIMEOUT = PREFIX_DISTRIBUTION_CLIENT - + "POLLING_TIMEOUT"; - protected static final String PROP_ML_DISTRIBUTION_USER = PREFIX_DISTRIBUTION_CLIENT + "USER"; - protected static final String PROP_ML_DISTRIBUTION_ARTIFACT_TYPES = PREFIX_DISTRIBUTION_CLIENT - + "ARTIFACT_TYPES"; - - protected static final String PROP_AAI_BASE_URL = PREFIX_AAI + "BASE_URL"; - protected static final String PROP_AAI_KEYSTORE_FILE = PREFIX_AAI + "KEYSTORE_FILE"; - protected static final String PROP_AAI_KEYSTORE_PASSWORD = PREFIX_AAI + "KEYSTORE_PASSWORD"; - protected static final String PROP_AAI_MODEL_RESOURCE_URL = PREFIX_AAI + "MODEL_URL"; - protected static final String PROP_AAI_NAMED_QUERY_RESOURCE_URL = PREFIX_AAI + "NAMED_QUERY_URL"; - protected static final String PROP_AAI_VNF_IMAGE_RESOURCE_URL = PREFIX_AAI + "VNF_IMAGE_URL"; - protected static final String PROP_AAI_AUTHENTICATION_USER = PREFIX_AAI + "AUTH_USER"; - protected static final String PROP_AAI_AUTHENTICATION_PASSWORD = PREFIX_AAI + "AUTH_PASSWORD"; - - protected static final String PROP_DEBUG_INGEST_SIMULATOR = PREFIX_DEBUG + "INGEST_SIMULATOR"; - - private Properties modelLoaderProperties = null; - - private String certLocation = "."; - - private List artifactTypes = null; - - /** - * This is the class constructor. - * - * @param modelLoaderProperties properties needed to be configured for the model loader - * @param certLocation location of the certificate - */ - public ModelLoaderConfig(Properties modelLoaderProperties) { - this.modelLoaderProperties = modelLoaderProperties; - - String aaiKeystoreFile = modelLoaderProperties.getProperty(PROP_AAI_KEYSTORE_FILE); - if(aaiKeystoreFile != null){ - URL keystoreURL = this.getClass().getClassLoader().getResource(aaiKeystoreFile); - if(keystoreURL != null){ - File fKeystoreLocation = new File(keystoreURL.getPath()); - this.certLocation = fKeystoreLocation.getParent(); - } - } - - // Get list of artifacts - artifactTypes = new ArrayList(); - if (modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ARTIFACT_TYPES) != null) { - String[] artTypeList = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ARTIFACT_TYPES) - .split(","); - for (String artType : artTypeList) { - artifactTypes.add(artType); - } - } - } - - @Override - public boolean activateServerTLSAuth() { - String value = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ACTIVE_SERVER_TLS_AUTH); - return value == null ? false : Boolean.parseBoolean(value); - } - - @Override - public String getAsdcAddress() { - return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ASDC_ADDRESS); - } - - @Override - public String getConsumerGroup() { - return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_CONSUMER_GROUP); - } - - @Override - public String getConsumerID() { - return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_CONSUMER_ID); - } - - @Override - public String getEnvironmentName() { - return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ENVIRONMENT_NAME); - } - - @Override - public String getKeyStorePassword() { - return Password - .deobfuscate(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD)); - } - - @Override - public String getKeyStorePath() { - return certLocation + modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_KEYSTORE_FILE); - } - - @Override - public String getPassword() { - return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_PASSWORD)); - } - - @Override - public int getPollingInterval() { - return Integer - .parseInt(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_POLLING_INTERVAL)); - } - - @Override - public int getPollingTimeout() { - return Integer - .parseInt(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_POLLING_TIMEOUT)); - } - - @Override - public List getRelevantArtifactTypes() { - return artifactTypes; - } - - @Override - public String getUser() { - return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_USER); - } - - public String getAaiKeyStorePath() { - return certLocation + "/" + modelLoaderProperties.getProperty(PROP_AAI_KEYSTORE_FILE); - } - - public String getAaiKeyStorePassword() { - return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_AAI_KEYSTORE_PASSWORD)); - } - - public String getAaiBaseUrl() { - return modelLoaderProperties.getProperty(PROP_AAI_BASE_URL); - } - - public String getAaiModelUrl() { - return modelLoaderProperties.getProperty(PROP_AAI_MODEL_RESOURCE_URL); - } - - public String getAaiNamedQueryUrl() { - return modelLoaderProperties.getProperty(PROP_AAI_NAMED_QUERY_RESOURCE_URL); - } - - public String getAaiVnfImageUrl() { - return modelLoaderProperties.getProperty(PROP_AAI_VNF_IMAGE_RESOURCE_URL); - } - - public String getAaiAuthenticationUser() { - return modelLoaderProperties.getProperty(PROP_AAI_AUTHENTICATION_USER); - } - - /** - * @return password for AAI authentication that has been reverse-engineered - * from its obfuscated form. - */ - public String getAaiAuthenticationPassword() { - String password = Password - .deobfuscate(modelLoaderProperties.getProperty(PROP_AAI_AUTHENTICATION_PASSWORD)); - - if ((password != null) && (password.equals(""))) { - return null; - } - - return password; - } - - /** - * @return a boolean value indicating whether the simulator is enabled. - */ - public boolean getIngestSimulatorEnabled() { - String propValue = modelLoaderProperties.getProperty(PROP_DEBUG_INGEST_SIMULATOR); - - if (propValue == null) { - return false; - } - - if (propValue.compareToIgnoreCase("enabled") == 0) { - return true; - } - - return false; - } -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.config; + +import org.eclipse.jetty.util.security.Password; +import org.openecomp.sdc.api.consumer.IConfiguration; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +public class ModelLoaderConfig implements IConfiguration { + + // Configuration file structure + public static final String PREFIX_MODEL_LOADER_CONFIG = "ml"; + public static final String PREFIX_DISTRIBUTION_CLIENT = + PREFIX_MODEL_LOADER_CONFIG + ".distribution."; + public static final String PREFIX_AAI = PREFIX_MODEL_LOADER_CONFIG + ".aai."; + public static final String PREFIX_DEBUG = PREFIX_MODEL_LOADER_CONFIG + ".debug."; + + // Configuration file properties + protected static final String PROP_ML_DISTRIBUTION_ACTIVE_SERVER_TLS_AUTH = + PREFIX_DISTRIBUTION_CLIENT + "ACTIVE_SERVER_TLS_AUTH"; + protected static final String PROP_ML_DISTRIBUTION_ASDC_ADDRESS = PREFIX_DISTRIBUTION_CLIENT + + "ASDC_ADDRESS"; + protected static final String PROP_ML_DISTRIBUTION_CONSUMER_GROUP = PREFIX_DISTRIBUTION_CLIENT + + "CONSUMER_GROUP"; + protected static final String PROP_ML_DISTRIBUTION_CONSUMER_ID = PREFIX_DISTRIBUTION_CLIENT + + "CONSUMER_ID"; + protected static final String PROP_ML_DISTRIBUTION_ENVIRONMENT_NAME = PREFIX_DISTRIBUTION_CLIENT + + "ENVIRONMENT_NAME"; + protected static final String PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD = PREFIX_DISTRIBUTION_CLIENT + + "KEYSTORE_PASSWORD"; + protected static final String PROP_ML_DISTRIBUTION_KEYSTORE_FILE = PREFIX_DISTRIBUTION_CLIENT + + "KEYSTORE_FILE"; + protected static final String PROP_ML_DISTRIBUTION_PASSWORD = PREFIX_DISTRIBUTION_CLIENT + + "PASSWORD"; + protected static final String PROP_ML_DISTRIBUTION_POLLING_INTERVAL = PREFIX_DISTRIBUTION_CLIENT + + "POLLING_INTERVAL"; + protected static final String PROP_ML_DISTRIBUTION_POLLING_TIMEOUT = PREFIX_DISTRIBUTION_CLIENT + + "POLLING_TIMEOUT"; + protected static final String PROP_ML_DISTRIBUTION_USER = PREFIX_DISTRIBUTION_CLIENT + "USER"; + protected static final String PROP_ML_DISTRIBUTION_ARTIFACT_TYPES = PREFIX_DISTRIBUTION_CLIENT + + "ARTIFACT_TYPES"; + + protected static final String PROP_AAI_BASE_URL = PREFIX_AAI + "BASE_URL"; + protected static final String PROP_AAI_KEYSTORE_FILE = PREFIX_AAI + "KEYSTORE_FILE"; + protected static final String PROP_AAI_KEYSTORE_PASSWORD = PREFIX_AAI + "KEYSTORE_PASSWORD"; + protected static final String PROP_AAI_MODEL_RESOURCE_URL = PREFIX_AAI + "MODEL_URL"; + protected static final String PROP_AAI_NAMED_QUERY_RESOURCE_URL = PREFIX_AAI + "NAMED_QUERY_URL"; + protected static final String PROP_AAI_VNF_IMAGE_RESOURCE_URL = PREFIX_AAI + "VNF_IMAGE_URL"; + protected static final String PROP_AAI_AUTHENTICATION_USER = PREFIX_AAI + "AUTH_USER"; + protected static final String PROP_AAI_AUTHENTICATION_PASSWORD = PREFIX_AAI + "AUTH_PASSWORD"; + + protected static final String PROP_DEBUG_INGEST_SIMULATOR = PREFIX_DEBUG + "INGEST_SIMULATOR"; + + private Properties modelLoaderProperties = null; + + private String certLocation = "."; + + private List artifactTypes = null; + + /** + * This is the class constructor. + * + * @param modelLoaderProperties properties needed to be configured for the model loader + * @param certLocation location of the certificate + */ + public ModelLoaderConfig(Properties modelLoaderProperties, String certLocation) { + this.modelLoaderProperties = modelLoaderProperties; + this.certLocation = certLocation; + + // Get list of artifacts + artifactTypes = new ArrayList(); + if (modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ARTIFACT_TYPES) != null) { + String[] artTypeList = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ARTIFACT_TYPES) + .split(","); + for (String artType : artTypeList) { + artifactTypes.add(artType); + } + } + } + + @Override + public boolean activateServerTLSAuth() { + String value = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ACTIVE_SERVER_TLS_AUTH); + return value == null ? false : Boolean.parseBoolean(value); + } + + @Override + public String getAsdcAddress() { + return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ASDC_ADDRESS); + } + + @Override + public String getConsumerGroup() { + return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_CONSUMER_GROUP); + } + + @Override + public String getConsumerID() { + return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_CONSUMER_ID); + } + + @Override + public String getEnvironmentName() { + return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ENVIRONMENT_NAME); + } + + @Override + public String getKeyStorePassword() { + return Password + .deobfuscate(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD)); + } + + @Override + public String getKeyStorePath() { + return certLocation + modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_KEYSTORE_FILE); + } + + @Override + public String getPassword() { + return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_PASSWORD)); + } + + @Override + public int getPollingInterval() { + return Integer + .parseInt(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_POLLING_INTERVAL)); + } + + @Override + public int getPollingTimeout() { + return Integer + .parseInt(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_POLLING_TIMEOUT)); + } + + @Override + public List getRelevantArtifactTypes() { + return artifactTypes; + } + + @Override + public String getUser() { + return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_USER); + } + + public String getAaiKeyStorePath() { + return certLocation + "/" + modelLoaderProperties.getProperty(PROP_AAI_KEYSTORE_FILE); + } + + public String getAaiKeyStorePassword() { + return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_AAI_KEYSTORE_PASSWORD)); + } + + public String getAaiBaseUrl() { + return modelLoaderProperties.getProperty(PROP_AAI_BASE_URL); + } + + public String getAaiModelUrl() { + return modelLoaderProperties.getProperty(PROP_AAI_MODEL_RESOURCE_URL); + } + + public String getAaiNamedQueryUrl() { + return modelLoaderProperties.getProperty(PROP_AAI_NAMED_QUERY_RESOURCE_URL); + } + + public String getAaiVnfImageUrl() { + return modelLoaderProperties.getProperty(PROP_AAI_VNF_IMAGE_RESOURCE_URL); + } + + public String getAaiAuthenticationUser() { + return modelLoaderProperties.getProperty(PROP_AAI_AUTHENTICATION_USER); + } + + /** + * @return password for AAI authentication that has been reverse-engineered + * from its obfuscated form. + */ + public String getAaiAuthenticationPassword() { + String password = Password + .deobfuscate(modelLoaderProperties.getProperty(PROP_AAI_AUTHENTICATION_PASSWORD)); + + if ((password != null) && (password.equals(""))) { + return null; + } + + return password; + } + + /** + * @return a boolean value indicating whether the simulator is enabled. + */ + public boolean getIngestSimulatorEnabled() { + String propValue = modelLoaderProperties.getProperty(PROP_DEBUG_INGEST_SIMULATOR); + + if (propValue == null) { + return false; + } + + if (propValue.compareToIgnoreCase("enabled") == 0) { + return true; + } + + return false; + } + + public boolean isFilterInEmptyResources() { + return false; + } + +} diff --git a/src/main/java/org/openecomp/modelloader/entity/Artifact.java b/src/main/java/org/openecomp/modelloader/entity/Artifact.java index fb0ec9f..30709ae 100644 --- a/src/main/java/org/openecomp/modelloader/entity/Artifact.java +++ b/src/main/java/org/openecomp/modelloader/entity/Artifact.java @@ -1,44 +1,46 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.entity; - -public abstract class Artifact { - - private String payload; - private ArtifactType type; - - public ArtifactType getType() { - return type; - } - - public void setType(ArtifactType type) { - this.type = type; - } - - public String getPayload() { - return payload; - } - - public void setPayload(String payload) { - this.payload = payload; - } - -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.entity; + +public abstract class Artifact { + + private String payload; + private ArtifactType type; + + public ArtifactType getType() { + return type; + } + + public void setType(ArtifactType type) { + this.type = type; + } + + public String getPayload() { + return payload; + } + + public void setPayload(String payload) { + this.payload = payload; + } + +} diff --git a/src/main/java/org/openecomp/modelloader/entity/ArtifactHandler.java b/src/main/java/org/openecomp/modelloader/entity/ArtifactHandler.java index 16f2c87..bd6a861 100644 --- a/src/main/java/org/openecomp/modelloader/entity/ArtifactHandler.java +++ b/src/main/java/org/openecomp/modelloader/entity/ArtifactHandler.java @@ -1,37 +1,39 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.entity; - -import org.openecomp.modelloader.config.ModelLoaderConfig; - -import java.util.List; - -public abstract class ArtifactHandler { - - protected ModelLoaderConfig config; - - public ArtifactHandler(ModelLoaderConfig config) { - this.config = config; - } - - public abstract boolean pushArtifacts(List artifacts, String distributionId); - -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.entity; + +import org.openecomp.modelloader.config.ModelLoaderConfig; + +import java.util.List; + +public abstract class ArtifactHandler { + + protected ModelLoaderConfig config; + + public ArtifactHandler(ModelLoaderConfig config) { + this.config = config; + } + + public abstract boolean pushArtifacts(List artifacts, String distributionId); + +} diff --git a/src/main/java/org/openecomp/modelloader/entity/ArtifactType.java b/src/main/java/org/openecomp/modelloader/entity/ArtifactType.java index 8977e3c..ae556bc 100644 --- a/src/main/java/org/openecomp/modelloader/entity/ArtifactType.java +++ b/src/main/java/org/openecomp/modelloader/entity/ArtifactType.java @@ -1,25 +1,27 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.entity; - -public enum ArtifactType { - MODEL, NAMED_QUERY, VNF_CATALOG; -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.entity; + +public enum ArtifactType { + MODEL, NAMED_QUERY, VNF_CATALOG; +} diff --git a/src/main/java/org/openecomp/modelloader/entity/catalog/VnfCatalogArtifact.java b/src/main/java/org/openecomp/modelloader/entity/catalog/VnfCatalogArtifact.java index b2e1fdb..a15ed3c 100644 --- a/src/main/java/org/openecomp/modelloader/entity/catalog/VnfCatalogArtifact.java +++ b/src/main/java/org/openecomp/modelloader/entity/catalog/VnfCatalogArtifact.java @@ -1,31 +1,33 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.entity.catalog; - -import org.openecomp.modelloader.entity.Artifact; -import org.openecomp.modelloader.entity.ArtifactType; - -public class VnfCatalogArtifact extends Artifact { - public VnfCatalogArtifact(String payload) { - setPayload(payload); - setType(ArtifactType.VNF_CATALOG); - } -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.entity.catalog; + +import org.openecomp.modelloader.entity.Artifact; +import org.openecomp.modelloader.entity.ArtifactType; + +public class VnfCatalogArtifact extends Artifact { + public VnfCatalogArtifact(String payload) { + setPayload(payload); + setType(ArtifactType.VNF_CATALOG); + } +} diff --git a/src/main/java/org/openecomp/modelloader/entity/catalog/VnfCatalogArtifactHandler.java b/src/main/java/org/openecomp/modelloader/entity/catalog/VnfCatalogArtifactHandler.java index 189b069..5c526a6 100644 --- a/src/main/java/org/openecomp/modelloader/entity/catalog/VnfCatalogArtifactHandler.java +++ b/src/main/java/org/openecomp/modelloader/entity/catalog/VnfCatalogArtifactHandler.java @@ -1,184 +1,192 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.entity.catalog; - -import com.sun.jersey.api.client.ClientResponse; - -import generated.VnfCatalog; -import generated.VnfCatalog.PartNumberList; - -import inventory.aai.openecomp.org.v8.VnfImage; - -import org.eclipse.persistence.jaxb.MarshallerProperties; -import org.openecomp.cl.api.Logger; -import org.openecomp.cl.eelf.LoggerFactory; -import org.openecomp.modelloader.config.ModelLoaderConfig; -import org.openecomp.modelloader.entity.Artifact; -import org.openecomp.modelloader.entity.ArtifactHandler; -import org.openecomp.modelloader.restclient.AaiRestClient; -import org.openecomp.modelloader.restclient.AaiRestClient.MimeType; -import org.openecomp.modelloader.service.ModelLoaderMsgs; - -import java.io.StringReader; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import javax.ws.rs.core.Response; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; - - -public class VnfCatalogArtifactHandler extends ArtifactHandler { - - private static Logger logger = LoggerFactory.getInstance() - .getLogger(VnfCatalogArtifactHandler.class.getName()); - - public VnfCatalogArtifactHandler(ModelLoaderConfig config) { - super(config); - } - - @Override - public boolean pushArtifacts(List artifacts, String distributionId) { - for (Artifact art : artifacts) { - VnfCatalogArtifact vnfCatalog = (VnfCatalogArtifact) art; - String artifactPayload = vnfCatalog.getPayload(); - - AaiRestClient restClient = new AaiRestClient(this.config); - List putImages = new ArrayList(); - - try { - JAXBContext inputContext = JAXBContext.newInstance(VnfCatalog.class); - Unmarshaller unmarshaller = inputContext.createUnmarshaller(); - StringReader reader = new StringReader(artifactPayload); - VnfCatalog cat = (VnfCatalog) unmarshaller.unmarshal(reader); - - int numParts = cat.getPartNumberList().size(); - - for (int i = 0; i < numParts; i++) { - - PartNumberList pnl = cat.getPartNumberList().get(i); - - String application = pnl.getVendorInfo().getVendorModel(); - String applicationVendor = pnl.getVendorInfo().getVendorName(); - - int numVersions = pnl.getSoftwareVersionList().size(); - - for (int j = 0; j < numVersions; j++) { - String applicationVersion = pnl.getSoftwareVersionList().get(j).getSoftwareVersion(); - - String imageId = "vnf image " + applicationVendor + " " + application + " " - + applicationVersion; - - String getUrl = config.getAaiBaseUrl() + config.getAaiVnfImageUrl() - + "?application-vendor=" + applicationVendor + "&application=" + application - + "&application-version=" + applicationVersion; - - ClientResponse tryGet = restClient.getResource(getUrl, distributionId, MimeType.JSON); - if (tryGet == null) { - logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, - "Ingestion failed on " + imageId + ". Rolling back distribution."); - failureCleanup(putImages, restClient, distributionId); - return false; - } - if (tryGet.getStatus() == Response.Status.NOT_FOUND.getStatusCode()) { - // this vnf-image not already in the db, need to add - // only do this on 404 bc other error responses could mean there - // are problems that - // you might not want to try to PUT against - - VnfImage image = new VnfImage(); - image.setApplication(application); - image.setApplicationVendor(applicationVendor); - image.setApplicationVersion(applicationVersion); - String uuid = UUID.randomUUID().toString(); - image.setUuid(uuid); // need to create uuid - - System.setProperty("javax.xml.bind.context.factory", - "org.eclipse.persistence.jaxb.JAXBContextFactory"); - JAXBContext jaxbContext = JAXBContext.newInstance(VnfImage.class); - Marshaller marshaller = jaxbContext.createMarshaller(); - marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, "application/json"); - marshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT, false); - marshaller.setProperty(MarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false); - StringWriter writer = new StringWriter(); - marshaller.marshal(image, writer); - String payload = writer.toString(); - - String putUrl = config.getAaiBaseUrl() + config.getAaiVnfImageUrl() + "/vnf-image/" - + uuid; - - ClientResponse putResp = restClient.putResource(putUrl, payload, distributionId, - MimeType.JSON); - if (putResp == null - || putResp.getStatus() != Response.Status.CREATED.getStatusCode()) { - logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, - "Ingestion failed on vnf-image " + imageId + ". Rolling back distribution."); - failureCleanup(putImages, restClient, distributionId); - return false; - } - putImages.add(image); - logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, imageId + " successfully ingested."); - } else if (tryGet.getStatus() == Response.Status.OK.getStatusCode()) { - logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, - imageId + " already exists. Skipping ingestion."); - } else { - // if other than 404 or 200, something went wrong - logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, - "Ingestion failed on vnf-image " + imageId + " with status " + tryGet.getStatus() - + ". Rolling back distribution."); - failureCleanup(putImages, restClient, distributionId); - return false; - } - } - } - - } catch (JAXBException e) { - logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, - "Ingestion failed. " + e.getMessage() + ". Rolling back distribution."); - failureCleanup(putImages, restClient, distributionId); - return false; - } - } - - return true; - } - - /* - * if something fails in the middle of ingesting the catalog we want to - * rollback any changes to the db - */ - private void failureCleanup(List putImages, AaiRestClient restClient, String transId) { - for (VnfImage image : putImages) { - String url = config.getAaiBaseUrl() + config.getAaiVnfImageUrl() + "/vnf-image/" - + image.getUuid(); - restClient.getAndDeleteResource(url, transId); // try to delete the image, - // if something goes wrong - // we can't really do - // anything here - } - } - -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.entity.catalog; + +import com.sun.jersey.api.client.ClientResponse; + +import generated.VnfCatalog; +import generated.VnfCatalog.PartNumberList; + +import inventory.aai.openecomp.org.v8.VnfImage; + +import org.eclipse.persistence.jaxb.MarshallerProperties; +import org.openecomp.cl.api.Logger; +import org.openecomp.cl.eelf.LoggerFactory; +import org.openecomp.modelloader.config.ModelLoaderConfig; +import org.openecomp.modelloader.entity.Artifact; +import org.openecomp.modelloader.entity.ArtifactHandler; +import org.openecomp.modelloader.restclient.AaiRestClient; +import org.openecomp.modelloader.restclient.AaiRestClient.MimeType; +import org.openecomp.modelloader.service.ModelLoaderMsgs; +import org.springframework.web.util.UriUtils; + +import java.io.StringReader; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import javax.ws.rs.core.Response; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; + + +public class VnfCatalogArtifactHandler extends ArtifactHandler { + + private static Logger logger = LoggerFactory.getInstance() + .getLogger(VnfCatalogArtifactHandler.class.getName()); + + public VnfCatalogArtifactHandler(ModelLoaderConfig config) { + super(config); + } + + @Override + public boolean pushArtifacts(List artifacts, String distributionId) { + for (Artifact art : artifacts) { + VnfCatalogArtifact vnfCatalog = (VnfCatalogArtifact) art; + String artifactPayload = vnfCatalog.getPayload(); + + AaiRestClient restClient = new AaiRestClient(this.config); + List putImages = new ArrayList(); + + try { + JAXBContext inputContext = JAXBContext.newInstance(VnfCatalog.class); + Unmarshaller unmarshaller = inputContext.createUnmarshaller(); + StringReader reader = new StringReader(artifactPayload); + VnfCatalog cat = (VnfCatalog) unmarshaller.unmarshal(reader); + + int numParts = cat.getPartNumberList().size(); + + for (int i = 0; i < numParts; i++) { + + PartNumberList pnl = cat.getPartNumberList().get(i); + + String application = pnl.getVendorInfo().getVendorModel(); + String applicationVendor = pnl.getVendorInfo().getVendorName(); + + int numVersions = pnl.getSoftwareVersionList().size(); + + for (int j = 0; j < numVersions; j++) { + String applicationVersion = pnl.getSoftwareVersionList().get(j).getSoftwareVersion(); + + String imageId = "vnf image " + applicationVendor + " " + application + " " + + applicationVersion; + + String queryURI = "application-vendor=" + applicationVendor + "&application=" + application + "&application-version=" + applicationVersion; + + String getUrl = config.getAaiBaseUrl() + config.getAaiVnfImageUrl() + "?" + UriUtils.encodePath(queryURI, "UTF-8"); + + ClientResponse tryGet = restClient.getResource(getUrl, distributionId, MimeType.JSON); + if (tryGet == null) { + logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, + "Ingestion failed on " + imageId + ". Rolling back distribution."); + failureCleanup(putImages, restClient, distributionId); + return false; + } + if (tryGet.getStatus() == Response.Status.NOT_FOUND.getStatusCode()) { + // this vnf-image not already in the db, need to add + // only do this on 404 bc other error responses could mean there + // are problems that + // you might not want to try to PUT against + + VnfImage image = new VnfImage(); + image.setApplication(application); + image.setApplicationVendor(applicationVendor); + image.setApplicationVersion(applicationVersion); + String uuid = UUID.randomUUID().toString(); + image.setUuid(uuid); // need to create uuid + + System.setProperty("javax.xml.bind.context.factory", + "org.eclipse.persistence.jaxb.JAXBContextFactory"); + JAXBContext jaxbContext = JAXBContext.newInstance(VnfImage.class); + Marshaller marshaller = jaxbContext.createMarshaller(); + marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, "application/json"); + marshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT, false); + marshaller.setProperty(MarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false); + StringWriter writer = new StringWriter(); + marshaller.marshal(image, writer); + String payload = writer.toString(); + + String putUrl = config.getAaiBaseUrl() + config.getAaiVnfImageUrl() + "/vnf-image/" + + uuid; + + ClientResponse putResp = restClient.putResource(putUrl, payload, distributionId, + MimeType.JSON); + if (putResp == null + || putResp.getStatus() != Response.Status.CREATED.getStatusCode()) { + logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, + "Ingestion failed on vnf-image " + imageId + ". Rolling back distribution."); + failureCleanup(putImages, restClient, distributionId); + return false; + } + putImages.add(image); + logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, imageId + " successfully ingested."); + } else if (tryGet.getStatus() == Response.Status.OK.getStatusCode()) { + logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, + imageId + " already exists. Skipping ingestion."); + } else { + // if other than 404 or 200, something went wrong + logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, + "Ingestion failed on vnf-image " + imageId + " with status " + tryGet.getStatus() + + ". Rolling back distribution."); + failureCleanup(putImages, restClient, distributionId); + return false; + } + } + } + + } catch (JAXBException e) { + logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, + "Ingestion failed. " + e.getMessage() + ". Rolling back distribution."); + failureCleanup(putImages, restClient, distributionId); + return false; + } catch (UnsupportedEncodingException e) { + logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, "Ingestion failed. " + e.getMessage() + ". Rolling back distribution."); + failureCleanup(putImages, restClient, distributionId); + return false; + } + } + + return true; + } + + /* + * if something fails in the middle of ingesting the catalog we want to + * rollback any changes to the db + */ + private void failureCleanup(List putImages, AaiRestClient restClient, String transId) { + for (VnfImage image : putImages) { + String url = config.getAaiBaseUrl() + config.getAaiVnfImageUrl() + "/vnf-image/" + + image.getUuid(); + restClient.getAndDeleteResource(url, transId); // try to delete the image, + // if something goes wrong + // we can't really do + // anything here + } + } + +} diff --git a/src/main/java/org/openecomp/modelloader/entity/model/ModelArtifact.java b/src/main/java/org/openecomp/modelloader/entity/model/ModelArtifact.java index 904dba9..14749e5 100644 --- a/src/main/java/org/openecomp/modelloader/entity/model/ModelArtifact.java +++ b/src/main/java/org/openecomp/modelloader/entity/model/ModelArtifact.java @@ -1,60 +1,134 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.entity.model; - -import org.openecomp.modelloader.entity.Artifact; - -import java.util.HashSet; -import java.util.Set; - -public class ModelArtifact extends Artifact { - - String nameVersionId; - Set referencedModelIds = new HashSet(); - - public String getNameVersionId() { - return nameVersionId; - } - - public void setNameVersionId(String nameVersionId) { - this.nameVersionId = nameVersionId; - } - - public Set getDependentModelIds() { - return referencedModelIds; - } - - public void addDependentModelId(String dependentModelId) { - this.referencedModelIds.add(dependentModelId); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("NameVersId=" + nameVersionId + "(" + getType().toString() + ") ==> "); - for (String dep : referencedModelIds) { - sb.append(dep + " "); - } - - return sb.toString(); - } - -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.entity.model; + +import org.openecomp.modelloader.entity.Artifact; +import org.w3c.dom.Node; + +import java.util.HashSet; +import java.util.Set; + +public class ModelArtifact extends Artifact { + + String modelVerId; + String modelInvariantId; + String nameVersionId; + String modelModelVerCombinedKey; + String modelVerModelVersionId; + String modelModelInvariantId; + String modelNamespace; + Set referencedModelIds = new HashSet(); + Node modelVer; + boolean isV9Artifact = true; + + public boolean isV9Artifact() { + return isV9Artifact; + } + + public void setV9Artifact(boolean isV9Artifact) { + this.isV9Artifact = isV9Artifact; + } + + public String getModelVerModelVersionId() { + return modelVerModelVersionId; + } + + public void setModelVerModelVersionId(String modelVerModelVersionId) { + this.modelVerModelVersionId = modelVerModelVersionId; + } + + public String getModelModelInvariantId() { + return modelModelInvariantId; + } + + public void setModelModelInvariantId(String modelModelInvariantId) { + this.modelModelInvariantId = modelModelInvariantId; + } + + public String getNameVersionId() { + return nameVersionId; + } + + public void setNameVersionId(String nameVersionId) { + this.nameVersionId = nameVersionId; + } + + public String getModelNamespace() { + return modelNamespace; + } + + public void setModelNamespace(String modelNamespace) { + this.modelNamespace = modelNamespace; + } + + public Set getDependentModelIds() { + return referencedModelIds; + } + + public void addDependentModelId(String dependentModelId) { + this.referencedModelIds.add(dependentModelId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("ModelInvariantId=" + modelInvariantId + "(" + getType().toString() + ") ==> "); + for (String dep : referencedModelIds) { + sb.append(dep + " "); + } + + return sb.toString(); + } + + public String getModelVerId() { + return modelVerId; + } + + public void setModelVerId(String modelVerId) { + this.modelVerId = modelVerId; + } + + public String getModelInvariantId() { + return modelInvariantId; + } + + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + + public Node getModelVer() { + return modelVer; + } + + public void setModelVer(Node modelVer) { + this.modelVer = modelVer; + } + + public String getModelModelVerCombinedKey() { + return getModelInvariantId() + "|" + getModelVerId(); + } + + public void setModelModelVerCombinedKey(String modelModelVerCombinedKey) { + this.modelModelVerCombinedKey = getModelInvariantId() + "|" + getModelVerId(); + } +} diff --git a/src/main/java/org/openecomp/modelloader/entity/model/ModelArtifactHandler.java b/src/main/java/org/openecomp/modelloader/entity/model/ModelArtifactHandler.java index fb269b1..ce6d986 100644 --- a/src/main/java/org/openecomp/modelloader/entity/model/ModelArtifactHandler.java +++ b/src/main/java/org/openecomp/modelloader/entity/model/ModelArtifactHandler.java @@ -1,133 +1,228 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.entity.model; - -import com.sun.jersey.api.client.ClientResponse; - -import org.openecomp.cl.api.Logger; -import org.openecomp.cl.eelf.LoggerFactory; -import org.openecomp.modelloader.config.ModelLoaderConfig; -import org.openecomp.modelloader.entity.Artifact; -import org.openecomp.modelloader.entity.ArtifactHandler; -import org.openecomp.modelloader.entity.ArtifactType; -import org.openecomp.modelloader.restclient.AaiRestClient; -import org.openecomp.modelloader.service.ModelLoaderMsgs; - -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.core.Response; - -public class ModelArtifactHandler extends ArtifactHandler { - - private static Logger logger = LoggerFactory.getInstance() - .getLogger(ArtifactHandler.class.getName()); - - public ModelArtifactHandler(ModelLoaderConfig config) { - super(config); - } - - @Override - public boolean pushArtifacts(List artifacts, String distributionId) { - ModelSorter modelSorter = new ModelSorter(); - List sortedModelArtifacts = modelSorter.sort(artifacts); - - // Push the ordered list of model artifacts to A&AI. If one fails, we need - // to roll back - // the changes. - List completedModels = new ArrayList(); - AaiRestClient aaiClient = new AaiRestClient(config); - - for (Artifact art : sortedModelArtifacts) { - ModelArtifact model = (ModelArtifact) art; - ClientResponse getResponse = aaiClient.getResource(getUrl(model), distributionId, - AaiRestClient.MimeType.XML); - if ((getResponse == null) - || (getResponse.getStatus() != Response.Status.OK.getStatusCode())) { - // Only attempt the PUT if the model doesn't already exist - ClientResponse putResponse = aaiClient.putResource(getUrl(model), model.getPayload(), - distributionId, AaiRestClient.MimeType.XML); - if ((putResponse != null) - && (putResponse.getStatus() == Response.Status.CREATED.getStatusCode())) { - completedModels.add(model); - logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, model.getType().toString() + " " - + model.getNameVersionId() + " successfully ingested."); - } else { - logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, - "Ingestion failed for " + model.getType().toString() + " " + model.getNameVersionId() - + ". Rolling back distribution."); - - for (ModelArtifact modelToDelete : completedModels) { - // Best effort to delete. Nothing we can do in the event this fails. - aaiClient.getAndDeleteResource(getUrl(modelToDelete), distributionId); - } - - return false; - } - } else { - logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, model.getType().toString() + " " - + model.getNameVersionId() + " already exists. Skipping ingestion."); - } - } - - return true; - } - - private String getUrl(ModelArtifact model) { - String baseUrl = config.getAaiBaseUrl().trim(); - String subUrl = null; - if (model.getType().equals(ArtifactType.MODEL)) { - subUrl = config.getAaiModelUrl().trim(); - } else { - subUrl = config.getAaiNamedQueryUrl().trim(); - } - - if ((!baseUrl.endsWith("/")) && (!subUrl.startsWith("/"))) { - baseUrl = baseUrl + "/"; - } - - if (baseUrl.endsWith("/") && subUrl.startsWith("/")) { - baseUrl = baseUrl.substring(0, baseUrl.length() - 1); - } - - if (!subUrl.endsWith("/")) { - subUrl = subUrl + "/"; - } - - String url = baseUrl + subUrl + model.getNameVersionId(); - return url; - } - - /** - * This method is used for the test REST interface to load models without an - * ASDC. - * - * @param payload content of the request - */ - public void loadModelTest(byte[] payload) { - List modelArtifacts = new ArrayList(); - ModelArtifactParser parser = new ModelArtifactParser(); - modelArtifacts.addAll(parser.parse(payload, "Test-Artifact")); - ModelSorter modelSorter = new ModelSorter(); - List sortedModelArtifacts = modelSorter.sort(modelArtifacts); - pushArtifacts(sortedModelArtifacts, "Test-Distribution"); - } -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.entity.model; + +import com.sun.jersey.api.client.ClientResponse; + +import org.openecomp.cl.api.Logger; +import org.openecomp.cl.eelf.LoggerFactory; +import org.openecomp.modelloader.config.ModelLoaderConfig; +import org.openecomp.modelloader.entity.Artifact; +import org.openecomp.modelloader.entity.ArtifactHandler; +import org.openecomp.modelloader.entity.ArtifactType; +import org.openecomp.modelloader.restclient.AaiRestClient; +import org.openecomp.modelloader.service.ModelLoaderMsgs; + +import org.w3c.dom.Node; + +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.List; + +import javax.ws.rs.core.Response; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + + +public class ModelArtifactHandler extends ArtifactHandler { + + private static final String AAI_MODEL_VER = "/model-vers/model-ver"; + private static Logger logger = LoggerFactory.getInstance().getLogger(ArtifactHandler.class.getName()); + + + public ModelArtifactHandler(ModelLoaderConfig config) { + super(config); + } + + @Override + public boolean pushArtifacts(List artifacts, String distributionID) { + ModelSorter modelSorter = new ModelSorter(); + List sortedModelArtifacts = modelSorter.sort(artifacts); + + // Push the ordered list of model artifacts to A&AI. If one fails, we need to roll back + // the changes. + List completedModels = new ArrayList(); + AaiRestClient aaiClient = new AaiRestClient(config); + + for (Artifact art : sortedModelArtifacts) { + ModelArtifact model = (ModelArtifact)art; + + boolean version = model.isV9Artifact(); + //Non - V9 version for models + if(version == false){ + ClientResponse getResponse = aaiClient.getResource(getModelVerURL(model), distributionID, AaiRestClient.MimeType.XML); + if ( (getResponse == null) || (getResponse.getStatus() != Response.Status.OK.getStatusCode()) ) { + logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, " Artifact format not valid for " + + model.getType().toString() + "- model-invariant-id[model-id]: " + + model.getModelInvariantId() + " and model-version-id[model-name-version-id]: "+ + model.getModelVerId()+ " . Rolling back distribution."); + return false; + } + else{ + completedModels.add(model); + logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, model.getType().toString() + + " " + model.getModelInvariantId() + " successfully ingested."); + } + } + else + { + ClientResponse getResponse = aaiClient.getResource(getURL(model), distributionID, AaiRestClient.MimeType.XML); + if ( (getResponse == null) || (getResponse.getStatus() != Response.Status.OK.getStatusCode()) ) { + // Only attempt the PUT if the model doesn't already exist + ClientResponse putResponse = aaiClient.putResource(getURL(model), model.getPayload(), distributionID, AaiRestClient.MimeType.XML); + if ( (putResponse != null) && (putResponse.getStatus() == Response.Status.CREATED.getStatusCode()) ) { + completedModels.add(model); + logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, model.getType().toString() + + " " + model.getModelInvariantId() + " successfully ingested."); + } + else { + logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, "Ingestion failed for " + + model.getType().toString() + " " + model.getModelInvariantId() + ". Rolling back distribution."); + + for (ModelArtifact modelToDelete : completedModels) { + // Best effort to delete. Nothing we can do in the event this fails. + aaiClient.getAndDeleteResource(getURL(modelToDelete), distributionID); + } + + return false; + } + } + else { + logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, model.getType().toString() + " " + model.getModelInvariantId() + + " already exists. Skipping ingestion."); + getResponse = aaiClient.getResource(getModelVerURL(model), distributionID, AaiRestClient.MimeType.XML); + if ( (getResponse == null) || (getResponse.getStatus() != Response.Status.OK.getStatusCode()) ) { + // Only attempt the PUT if the model-ver doesn't already exist + ClientResponse putResponse = null; + + try { + putResponse = aaiClient.putResource(getModelVerURL(model), nodeToString(model.getModelVer()), distributionID, AaiRestClient.MimeType.XML); + } catch (TransformerException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if ( (putResponse != null) && (putResponse.getStatus() == Response.Status.CREATED.getStatusCode()) ) { + completedModels.add(model); + logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, model.getType().toString() + " " + + model.getNameVersionId() + " successfully ingested."); + } + else { + logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, "Ingestion failed for " + + model.getType().toString() + " " + model.getNameVersionId() + ". Rolling back distribution."); + + for (ModelArtifact modelToDelete : completedModels) { + // Best effort to delete. Nothing we can do in the event this fails. + aaiClient.getAndDeleteResource(getModelVerURL(modelToDelete), distributionID); + } + + return false; + } + } + else { + logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, model.getType().toString() + " " + + model.getModelInvariantId() + " already exists. Skipping ingestion."); + } + } + } + } + + return true; + } + + + private String nodeToString(Node node) throws TransformerException { + StringWriter sw = new StringWriter(); + Transformer t = TransformerFactory.newInstance().newTransformer(); + t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + t.transform(new DOMSource(node), new StreamResult(sw)); + System.out.println(sw.toString()); + return sw.toString(); + } + + private String getURL(ModelArtifact model) { + String baseURL = config.getAaiBaseUrl().trim(); + String subURL = null; + if (model.getType().equals(ArtifactType.MODEL)) { + subURL = config.getAaiModelUrl().trim(); + } + else { + subURL = config.getAaiNamedQueryUrl().trim(); + } + + if ( (!baseURL.endsWith("/")) && (!subURL.startsWith("/")) ) { + baseURL = baseURL + "/"; + } + + if ( baseURL.endsWith("/") && subURL.startsWith("/") ) { + baseURL = baseURL.substring(0, baseURL.length()-1); + } + + if (!subURL.endsWith("/")) { + subURL = subURL + "/"; + } + + String url = baseURL + subURL + model.getModelInvariantId(); + return url; + } + + private String getModelVerURL(ModelArtifact model) { + String baseURL = config.getAaiBaseUrl().trim(); + String subURL = null; + if (model.getType().equals(ArtifactType.MODEL)) { + subURL = config.getAaiModelUrl().trim() + model.getModelInvariantId() + AAI_MODEL_VER; + } + else { + subURL = config.getAaiNamedQueryUrl().trim(); + } + + if ( (!baseURL.endsWith("/")) && (!subURL.startsWith("/")) ) { + baseURL = baseURL + "/"; + } + + if ( baseURL.endsWith("/") && subURL.startsWith("/") ) { + baseURL = baseURL.substring(0, baseURL.length()-1); + } + + if (!subURL.endsWith("/")) { + subURL = subURL + "/"; + } + + String url = baseURL + subURL + model.getModelVerId(); + System.out.println(url); + return url; + } + + // This method is used for the test REST interface to load models without an ASDC + public void loadModelTest(byte[] payload) { + List modelArtifacts = new ArrayList(); + ModelArtifactParser parser = new ModelArtifactParser(); + modelArtifacts.addAll(parser.parse(payload, "Test-Artifact")); + ModelSorter modelSorter = new ModelSorter(); + List sortedModelArtifacts = modelSorter.sort(modelArtifacts); + pushArtifacts(sortedModelArtifacts, "Test-Distribution"); + } +} diff --git a/src/main/java/org/openecomp/modelloader/entity/model/ModelArtifactParser.java b/src/main/java/org/openecomp/modelloader/entity/model/ModelArtifactParser.java index 625145f..de27924 100644 --- a/src/main/java/org/openecomp/modelloader/entity/model/ModelArtifactParser.java +++ b/src/main/java/org/openecomp/modelloader/entity/model/ModelArtifactParser.java @@ -1,197 +1,265 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.entity.model; - -import org.openecomp.cl.api.Logger; -import org.openecomp.cl.eelf.LoggerFactory; -import org.openecomp.modelloader.entity.Artifact; -import org.openecomp.modelloader.entity.ArtifactType; -import org.openecomp.modelloader.service.ModelLoaderMsgs; -import org.openecomp.modelloader.util.JsonXmlConverter; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; - -import java.io.StringReader; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -public class ModelArtifactParser { - - private static String MODELS_ELEMENT = "models"; - private static String MODEL_ELEMENT = "model"; - private static String NAMED_QUERIES_ELEMENT = "named-queries"; - private static String NAMED_QUERY_ELEMENT = "named-query"; - private static String MODEL_NAME_VERSION_ID = "model-name-version-id"; - private static String NAMED_QUERY_VERSION_ID = "named-query-uuid"; - private static String RELATIONSHIP_DATA = "relationship-data"; - private static String RELATIONSHIP_KEY = "relationship-key"; - private static String RELATIONSHIP_VALUE = "relationship-value"; - private static String MODEL_ELEMENT_RELATIONSHIP_KEY = "model.model-name-version-id"; - - private static Logger logger = LoggerFactory.getInstance() - .getLogger(ModelArtifactParser.class.getName()); - - /** - * This method parses the given artifact payload in byte array format and - * generates a list of model artifacts according to the content. - * - * @param artifactPayload - * artifact content to be parsed - * @param artifactName - * name of the artifact - * @return a list of model artifacts - */ - public List parse(byte[] artifactPayload, String artifactName) { - String payload = new String(artifactPayload); - List modelList = new ArrayList(); - - try { - // Artifact could be JSON or XML - if (JsonXmlConverter.isValidJson(payload)) { - payload = JsonXmlConverter.convertJsonToXml(payload); - } - - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - InputSource is = new InputSource(new StringReader(payload)); - Document doc = builder.parse(is); - - if ((doc.getDocumentElement().getNodeName().equalsIgnoreCase(MODEL_ELEMENT)) - || (doc.getDocumentElement().getNodeName().equalsIgnoreCase(NAMED_QUERY_ELEMENT))) { - ModelArtifact model = parseModel(doc.getDocumentElement(), payload); - if (model != null) { - modelList.add(model); - } else { - // TODO: A WARN message? - logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, - "Unable to parse artifact " + artifactName); - } - } else if ((doc.getDocumentElement().getNodeName().equalsIgnoreCase(MODELS_ELEMENT)) - || (doc.getDocumentElement().getNodeName().equalsIgnoreCase(NAMED_QUERIES_ELEMENT))) { - // The complete set of models/named-queries were contained in this - // artifact - NodeList nodeList = doc.getDocumentElement().getChildNodes(); - for (int i = 0; i < nodeList.getLength(); i++) { - Node childNode = nodeList.item(i); - if ((childNode.getNodeName().equalsIgnoreCase(MODEL_ELEMENT)) - || (childNode.getNodeName().equalsIgnoreCase(NAMED_QUERY_ELEMENT))) { - String modelPayload = nodeToString(childNode); - ModelArtifact model = parseModel(childNode, modelPayload); - if (model != null) { - modelList.add(model); - } else { - // TODO: A WARN message? - logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, - "Unable to parse artifact " + artifactName); - modelList.clear(); - break; - } - } - } - } - } catch (Exception ex) { - // This may not be an error. We may be receiving an artifact that is - // unrelated - // to models. In this case, we just ignore it. - // TODO: A WARN message? - logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, - "Unable to parse artifact " + artifactName + ": " + ex.getLocalizedMessage()); - } - - return modelList; - } - - private ModelArtifact parseModel(Node modelNode, String payload) { - ModelArtifact model = new ModelArtifact(); - model.setPayload(payload); - - if (modelNode.getNodeName().equalsIgnoreCase(MODEL_ELEMENT)) { - model.setType(ArtifactType.MODEL); - } else { - model.setType(ArtifactType.NAMED_QUERY); - } - - parseNode(modelNode, model); - - if (model.getNameVersionId() == null) { - return null; - } - - return model; - } - - private void parseNode(Node node, ModelArtifact model) { - if (node.getNodeName().equalsIgnoreCase(MODEL_NAME_VERSION_ID)) { - model.setNameVersionId(node.getTextContent().trim()); - } else if (node.getNodeName().equalsIgnoreCase(NAMED_QUERY_VERSION_ID)) { - model.setNameVersionId(node.getTextContent().trim()); - } else if (node.getNodeName().equalsIgnoreCase(RELATIONSHIP_DATA)) { - parseRelationshipNode(node, model); - } else { - NodeList nodeList = node.getChildNodes(); - for (int i = 0; i < nodeList.getLength(); i++) { - Node childNode = nodeList.item(i); - parseNode(childNode, model); - } - } - } - - private void parseRelationshipNode(Node node, ModelArtifact model) { - String key = null; - String value = null; - - NodeList nodeList = node.getChildNodes(); - for (int i = 0; i < nodeList.getLength(); i++) { - Node childNode = nodeList.item(i); - if (childNode.getNodeName().equalsIgnoreCase(RELATIONSHIP_KEY)) { - key = childNode.getTextContent().trim(); - } else if (childNode.getNodeName().equalsIgnoreCase(RELATIONSHIP_VALUE)) { - value = childNode.getTextContent().trim(); - } - } - - if ((key != null) && (key.equalsIgnoreCase(MODEL_ELEMENT_RELATIONSHIP_KEY))) { - if (value != null) { - model.addDependentModelId(value); - } - } - } - - private String nodeToString(Node node) throws TransformerException { - StringWriter sw = new StringWriter(); - Transformer transfomer = TransformerFactory.newInstance().newTransformer(); - transfomer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); - transfomer.transform(new DOMSource(node), new StreamResult(sw)); - return sw.toString(); - } -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.entity.model; + +import org.openecomp.cl.api.Logger; +import org.openecomp.cl.eelf.LoggerFactory; +import org.openecomp.modelloader.entity.Artifact; +import org.openecomp.modelloader.entity.ArtifactType; +import org.openecomp.modelloader.service.ModelLoaderMsgs; +import org.openecomp.modelloader.util.JsonXmlConverter; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; + +import java.io.StringReader; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + + +public class ModelArtifactParser { + + private static String MODELS_ELEMENT = "models"; + private static String MODEL_ELEMENT = "model"; + private static String NAMED_QUERIES_ELEMENT = "named-queries"; + private static String NAMED_QUERY_ELEMENT = "named-query"; + private static String MODEL_NAME_VERSION_ID = "model-name-version-id"; + private static String MODEL_VER = "model-ver"; + private static String MODEL_VERSION_ID = "model-version-id"; + private static String MODEL_INVARIANT_ID = "model-invariant-id"; + private static String NAMED_QUERY_VERSION_ID = "named-query-uuid"; + private static String RELATIONSHIP_DATA = "relationship-data"; + private static String RELATIONSHIP_KEY = "relationship-key"; + private static String RELATIONSHIP_VALUE = "relationship-value"; + private static String MODEL_ELEMENT_RELATIONSHIP_KEY = "model.model-invariant-id"; + private static String MODEL_VER_ELEMENT_RELATIONSHIP_KEY = "model-ver.model-version-id"; + + private static Logger logger = LoggerFactory.getInstance().getLogger(ModelArtifactParser.class.getName()); + + public List parse(byte[] artifactPayload, String artifactName) { + String payload = new String(artifactPayload); + List modelList = new ArrayList(); + + try { + // Artifact could be JSON or XML + if (JsonXmlConverter.isValidJson(payload)) { + payload = JsonXmlConverter.convertJsonToXml(payload); + } + + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + InputSource is = new InputSource(new StringReader(payload)); + Document doc = builder.parse(is); + + if ( (doc.getDocumentElement().getNodeName().equalsIgnoreCase(MODEL_ELEMENT)) || + (doc.getDocumentElement().getNodeName().equalsIgnoreCase(NAMED_QUERY_ELEMENT)) ) { + + ModelArtifact model = parseModel(doc.getDocumentElement(), payload); + + if (model != null) { + if ( ArtifactType.MODEL.equals(model.getType())) { + logger.info( ModelLoaderMsgs.DISTRIBUTION_EVENT, "Model parsed =====>>>> " + + "Model-invariant-Id: "+ model.getModelInvariantId() + + " Model-Version-Id: "+ model.getModelVerId()); + } + modelList.add(model); + } + else { + logger.error(ModelLoaderMsgs.ARTIFACT_PARSE_ERROR, "Unable to parse artifact " + artifactName); + return null; + } + } + else if ( (doc.getDocumentElement().getNodeName().equalsIgnoreCase(MODELS_ELEMENT)) || + (doc.getDocumentElement().getNodeName().equalsIgnoreCase(NAMED_QUERIES_ELEMENT)) ) { + // The complete set of models/named-queries were contained in this artifact + NodeList nodeList = doc.getDocumentElement().getChildNodes(); + for (int i = 0; i < nodeList.getLength(); i++) { + Node childNode = nodeList.item(i); + if ( (childNode.getNodeName().equalsIgnoreCase(MODEL_ELEMENT)) || + (childNode.getNodeName().equalsIgnoreCase(NAMED_QUERY_ELEMENT)) ) { + String modelPayload = nodeToString(childNode); + ModelArtifact model = parseModel(childNode, modelPayload); + if (model != null) { + modelList.add(model); + } + else { + logger.error(ModelLoaderMsgs.ARTIFACT_PARSE_ERROR, "Unable to parse artifact " + artifactName); + modelList.clear(); + break; + } + } + } + } + } + catch (Exception ex) { + logger.error(ModelLoaderMsgs.ARTIFACT_PARSE_ERROR, "Unable to parse artifact " + artifactName + ": " + ex.getLocalizedMessage()); + } + + return modelList; + } + + private void printDetails(Node modelVer) throws TransformerException { + logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, nodeToString(modelVer)); + } + + private ModelArtifact parseModel(Node modelNode, String payload) { + ModelArtifact model = new ModelArtifact(); + model.setPayload(payload); + + if (modelNode.getNodeName().equalsIgnoreCase(MODEL_ELEMENT)) { + //compare with Model-ver + model.setType(ArtifactType.MODEL); + } + else { + model.setType(ArtifactType.NAMED_QUERY); + } + + Element e = (Element)modelNode; + model.setModelNamespace(e.getAttribute("xmlns")); + + parseNode(modelNode, model); + + if (model.getModelInvariantId() == null && model.getNameVersionId() == null) { + return null; + } + + return model; + } + + private void parseNode(Node node, ModelArtifact model) { + + if(node.getNodeName().equalsIgnoreCase(MODEL_NAME_VERSION_ID)){ + model.setModelVerId(node.getTextContent().trim()); + model.setV9Artifact(false); + } + else if(node.getNodeName().equalsIgnoreCase("model-id")){ + model.setModelInvariantId(node.getTextContent().trim()); + model.setV9Artifact(false); + } + + else if (node.getNodeName().equalsIgnoreCase(MODEL_INVARIANT_ID)) { + model.setModelInvariantId(node.getTextContent().trim()); + } + else if (node.getNodeName().equalsIgnoreCase(MODEL_VERSION_ID)) { + model.setModelVerId(node.getTextContent().trim()); + //Change to Model Invariant Id + } + else if (node.getNodeName().equalsIgnoreCase(NAMED_QUERY_VERSION_ID)) { + model.setNameVersionId(node.getTextContent().trim()); + } + else if (node.getNodeName().equalsIgnoreCase(RELATIONSHIP_DATA)) { + parseRelationshipNode(node, model); + if(model.getModelModelInvariantId()!=null && model.getModelVerModelVersionId()!=null && !model.getModelModelInvariantId().isEmpty() && !model.getModelVerModelVersionId().isEmpty()){ + model.addDependentModelId(model.getModelModelInvariantId() + "|" + model.getModelVerModelVersionId()); + model.setModelModelInvariantId(""); + model.setModelVerModelVersionId(""); + } + } + else { + + if (node.getNodeName().equalsIgnoreCase(MODEL_VER)) { + model.setModelVer(node); + if ( (model.getModelNamespace() != null) && (!model.getModelNamespace().isEmpty()) ) { + Element e = (Element) node; + e.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns", model.getModelNamespace()); + System.out.println("Setting NS: " + e.getAttribute("xmlns")); + } + } + + NodeList nodeList = node.getChildNodes(); + + for (int i = 0; i < nodeList.getLength(); i++) { + Node childNode = nodeList.item(i); + parseNode(childNode, model); + } + } + } + + private void parseRelationshipNode(Node node, ModelArtifact model) { + + //invariant-id comes before model-version-id .. create a list of values + String key = null; + String value = null; + String modelVersionIdKey=null; + String modelInvariantIdIdKey=null; + String modelVersionIdValue=null; + String modelInvariantIdIdValue=null; + + NodeList nodeList = node.getChildNodes(); + for (int i = 0; i < nodeList.getLength(); i++) { + Node childNode = nodeList.item(i); + + + if (childNode.getNodeName().equalsIgnoreCase(RELATIONSHIP_KEY)) { + key = childNode.getTextContent().trim(); + if(key.equalsIgnoreCase(MODEL_VER_ELEMENT_RELATIONSHIP_KEY)){ + modelVersionIdKey = key; + } + else if(key.equalsIgnoreCase(MODEL_ELEMENT_RELATIONSHIP_KEY)){ + modelInvariantIdIdKey = key; + } + } + else if (childNode.getNodeName().equalsIgnoreCase(RELATIONSHIP_VALUE)) { + value = childNode.getTextContent().trim(); + if(modelVersionIdKey!=null){ + modelVersionIdValue = value; + model.setModelVerModelVersionId(modelVersionIdValue); + } + else if(modelInvariantIdIdKey!=null){ + modelInvariantIdIdValue = value; + model.setModelModelInvariantId(modelInvariantIdIdValue); + } + + } + } + + if ( (key != null) && (key.equalsIgnoreCase(MODEL_ELEMENT_RELATIONSHIP_KEY )) && + (model.isV9Artifact == false ||ArtifactType.NAMED_QUERY.equals(model.getType())) ) { + if (value != null) { + model.addDependentModelId(value); + } + } + } + + private String nodeToString(Node node) throws TransformerException { + StringWriter sw = new StringWriter(); + Transformer t = TransformerFactory.newInstance().newTransformer(); + t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + t.transform(new DOMSource(node), new StreamResult(sw)); + return sw.toString(); + } +} diff --git a/src/main/java/org/openecomp/modelloader/entity/model/ModelSorter.java b/src/main/java/org/openecomp/modelloader/entity/model/ModelSorter.java index 4dcda71..79f1c29 100644 --- a/src/main/java/org/openecomp/modelloader/entity/model/ModelSorter.java +++ b/src/main/java/org/openecomp/modelloader/entity/model/ModelSorter.java @@ -1,233 +1,235 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.entity.model; - -import jline.internal.Log; - -import org.openecomp.modelloader.entity.Artifact; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; - -/** - * Utility class to sort the given Models according to their dependencies. - * Example: Given a list of Models [A, B, C] where B depends on A, and A depends - * on C, the sorted result will be [C, A, B] - */ -public class ModelSorter { - - /** - * Wraps a Model object to form dependencies other Models using Edges. - */ - static class Node { - private final ModelArtifact model; - private final HashSet inEdges; - private final HashSet outEdges; - - public Node(ModelArtifact model) { - this.model = model; - inEdges = new HashSet(); - outEdges = new HashSet(); - } - - public Node addEdge(Node node) { - Edge edge = new Edge(this, node); - outEdges.add(edge); - node.inEdges.add(edge); - return this; - } - - @Override - public String toString() { - return model.getNameVersionId(); - } - - @Override - public boolean equals(Object other) { - ModelArtifact otherModel = ((Node) other).model; - return this.model.getNameVersionId().equals(otherModel.getNameVersionId()); - } - - @Override - public int hashCode() { - return this.model.getNameVersionId().hashCode(); - - } - } - - /** - * Represents a dependency between two Nodes. - */ - static class Edge { - public final Node from; - public final Node to; - - public Edge(Node from, Node to) { - this.from = from; - this.to = to; - } - - @Override - public boolean equals(Object obj) { - Edge edge = (Edge) obj; - return edge.from == from && edge.to == to; - } - } - - /** - * Returns the list of models sorted by order of dependency. - * - * @param originalList - * the list that needs to be sorted - * @return a list of sorted models - */ - public List sort(List originalList) { - - if (originalList.size() <= 1) { - return originalList; - } - - Collection nodes = createNodes(originalList); - Collection sortedNodes = sortNodes(nodes); - - List sortedModelsList = new ArrayList(sortedNodes.size()); - for (Node node : sortedNodes) { - sortedModelsList.add(node.model); - } - - return sortedModelsList; - } - - /** - * Create nodes from the list of models and their dependencies. - * - * @param models - * what the nodes creation is based upon - * @return Collection of Node objects - */ - private Collection createNodes(Collection models) { - - // load list of models into a map, so we can later replace referenceIds with - // real Models - HashMap versionIdToModelMap = new HashMap(); - for (Artifact art : models) { - ModelArtifact ma = (ModelArtifact) art; - versionIdToModelMap.put(ma.getNameVersionId(), ma); - } - - HashMap nodes = new HashMap(); - // create a node for each model and its referenced models - for (Artifact art : models) { - ModelArtifact model = (ModelArtifact) art; - - // node might have been created by another model referencing it - Node node = nodes.get(model.getNameVersionId()); - - if (null == node) { - node = new Node(model); - nodes.put(model.getNameVersionId(), node); - } - - for (String referencedModelId : model.getDependentModelIds()) { - // node might have been created by another model referencing it - Node referencedNode = nodes.get(referencedModelId); - - if (null == referencedNode) { - // create node - ModelArtifact referencedModel = versionIdToModelMap.get(referencedModelId); - if (referencedModel == null) { - Log.debug("ignoring " + referencedModelId); - continue; // referenced model not supplied, no need to sort it - } - referencedNode = new Node(referencedModel); - nodes.put(referencedModelId, referencedNode); - } - referencedNode.addEdge(node); - } - } - - return nodes.values(); - } - - /** - * Sorts the given Nodes by order of dependency. - * - * @param originalList - * the collection of nodes to be sorted - * @return a sorted collection of the given nodes - */ - private Collection sortNodes(Collection unsortedNodes) { - - // L <- Empty list that will contain the sorted elements - ArrayList nodeList = new ArrayList(); - - // S <- Set of all nodes with no incoming edges - HashSet nodeSet = new HashSet(); - for (Node unsortedNode : unsortedNodes) { - if (unsortedNode.inEdges.size() == 0) { - nodeSet.add(unsortedNode); - } - } - - // while S is non-empty do - while (!nodeSet.isEmpty()) { - // remove a node n from S - Node node = nodeSet.iterator().next(); - nodeSet.remove(node); - - // insert n into L - nodeList.add(node); - - // for each node m with an edge e from n to m do - for (Iterator it = node.outEdges.iterator(); it.hasNext();) { - // remove edge e from the graph - Edge edge = it.next(); - Node to = edge.to; - it.remove();// Remove edge from n - to.inEdges.remove(edge);// Remove edge from m - - // if m has no other incoming edges then insert m into S - if (to.inEdges.isEmpty()) { - nodeSet.add(to); - } - } - } - // Check to see if all edges are removed - boolean cycle = false; - for (Node node : unsortedNodes) { - if (!node.inEdges.isEmpty()) { - cycle = true; - break; - } - } - if (cycle) { - throw new RuntimeException( - "Circular dependency present between models, topological sort not possible"); - } - - return nodeList; - } - -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.entity.model; + +import jline.internal.Log; + +import org.openecomp.modelloader.entity.Artifact; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; + +/** + * Utility class to sort the given Models according to their dependencies. + * Example: Given a list of Models [A, B, C] where B depends on A, and A depends + * on C, the sorted result will be [C, A, B] + */ +public class ModelSorter { + + /** + * Wraps a Model object to form dependencies other Models using Edges. + */ + static class Node { + private final ModelArtifact model; + private final HashSet inEdges; + private final HashSet outEdges; + + public Node(ModelArtifact model) { + this.model = model; + inEdges = new HashSet(); + outEdges = new HashSet(); + } + + public Node addEdge(Node node) { + Edge edge = new Edge(this, node); + outEdges.add(edge); + node.inEdges.add(edge); + return this; + } + + @Override + public String toString() { + return model.getModelInvariantId(); + } + + @Override + public boolean equals(Object other) { + ModelArtifact otherModel = ((Node) other).model; + return this.model.getModelInvariantId().equals(otherModel.getModelInvariantId()); + } + + @Override + public int hashCode() { + return this.model.getModelInvariantId().hashCode(); + + } + } + + /** + * Represents a dependency between two Nodes. + */ + static class Edge { + public final Node from; + public final Node to; + + public Edge(Node from, Node to) { + this.from = from; + this.to = to; + } + + @Override + public boolean equals(Object obj) { + Edge edge = (Edge) obj; + return edge.from == from && edge.to == to; + } + } + + /** + * Returns the list of models sorted by order of dependency. + * + * @param originalList + * the list that needs to be sorted + * @return a list of sorted models + */ + public List sort(List originalList) { + + if (originalList.size() <= 1) { + return originalList; + } + + Collection nodes = createNodes(originalList); + Collection sortedNodes = sortNodes(nodes); + + List sortedModelsList = new ArrayList(sortedNodes.size()); + for (Node node : sortedNodes) { + sortedModelsList.add(node.model); + } + + return sortedModelsList; + } + + /** + * Create nodes from the list of models and their dependencies. + * + * @param models + * what the nodes creation is based upon + * @return Collection of Node objects + */ + private Collection createNodes(Collection models) { + + // load list of models into a map, so we can later replace referenceIds with + // real Models + HashMap versionIdToModelMap = new HashMap(); + for (Artifact art : models) { + ModelArtifact ma = (ModelArtifact) art; + versionIdToModelMap.put(ma.getModelModelVerCombinedKey(), ma); + } + + HashMap nodes = new HashMap(); + // create a node for each model and its referenced models + for (Artifact art : models) { + ModelArtifact model = (ModelArtifact) art; + + // node might have been created by another model referencing it + Node node = nodes.get(model.getModelModelVerCombinedKey()); + + if (null == node) { + node = new Node(model); + nodes.put(model.getModelModelVerCombinedKey(), node); + } + + for (String referencedModelId : model.getDependentModelIds()) { + // node might have been created by another model referencing it + Node referencedNode = nodes.get(referencedModelId); + + if (null == referencedNode) { + // create node + ModelArtifact referencedModel = versionIdToModelMap.get(referencedModelId); + if (referencedModel == null) { + Log.debug("ignoring " + referencedModelId); + continue; // referenced model not supplied, no need to sort it + } + referencedNode = new Node(referencedModel); + nodes.put(referencedModelId, referencedNode); + } + referencedNode.addEdge(node); + } + } + + return nodes.values(); + } + + /** + * Sorts the given Nodes by order of dependency. + * + * @param originalList + * the collection of nodes to be sorted + * @return a sorted collection of the given nodes + */ + private Collection sortNodes(Collection unsortedNodes) { + + // L <- Empty list that will contain the sorted elements + ArrayList nodeList = new ArrayList(); + + // S <- Set of all nodes with no incoming edges + HashSet nodeSet = new HashSet(); + for (Node unsortedNode : unsortedNodes) { + if (unsortedNode.inEdges.size() == 0) { + nodeSet.add(unsortedNode); + } + } + + // while S is non-empty do + while (!nodeSet.isEmpty()) { + // remove a node n from S + Node node = nodeSet.iterator().next(); + nodeSet.remove(node); + + // insert n into L + nodeList.add(node); + + // for each node m with an edge e from n to m do + for (Iterator it = node.outEdges.iterator(); it.hasNext();) { + // remove edge e from the graph + Edge edge = it.next(); + Node to = edge.to; + it.remove();// Remove edge from n + to.inEdges.remove(edge);// Remove edge from m + + // if m has no other incoming edges then insert m into S + if (to.inEdges.isEmpty()) { + nodeSet.add(to); + } + } + } + // Check to see if all edges are removed + boolean cycle = false; + for (Node node : unsortedNodes) { + if (!node.inEdges.isEmpty()) { + cycle = true; + break; + } + } + if (cycle) { + throw new RuntimeException( + "Circular dependency present between models, topological sort not possible"); + } + + return nodeList; + } + +} diff --git a/src/main/java/org/openecomp/modelloader/notification/DistributionStatusMsg.java b/src/main/java/org/openecomp/modelloader/notification/DistributionStatusMsg.java index 6079d5d..0ef2a42 100644 --- a/src/main/java/org/openecomp/modelloader/notification/DistributionStatusMsg.java +++ b/src/main/java/org/openecomp/modelloader/notification/DistributionStatusMsg.java @@ -1,75 +1,77 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.notification; - -import org.openecomp.sdc.api.consumer.IDistributionStatusMessage; -import org.openecomp.sdc.utils.DistributionStatusEnum; - -public class DistributionStatusMsg implements IDistributionStatusMessage { - private DistributionStatusEnum status; - private String distributionId; - private String consumerId; - private String artifactUrl; - - /** - * Creates a new DistributionStatusMsg instance. - * - * @param status - The distribution status to be reported. - * @param distributionId - The identifier of the distribution who's status is being rported on. - * @param consumerId - Identifier of the consumer associated with the distribution. - * @param artifactUrl - Resource identifier for the artifact. - */ - public DistributionStatusMsg(DistributionStatusEnum status, - String distributionId, - String consumerId, - String artifactUrl) { - this.status = status; - this.distributionId = distributionId; - this.consumerId = consumerId; - this.artifactUrl = artifactUrl; - } - - @Override - public long getTimestamp() { - long currentTimeMillis = System.currentTimeMillis(); - return currentTimeMillis; - } - - @Override - public DistributionStatusEnum getStatus() { - return status; - } - - @Override - public String getDistributionID() { - return distributionId; - } - - @Override - public String getConsumerID() { - return consumerId; - } - - @Override - public String getArtifactURL() { - return artifactUrl; - } -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.notification; + +import org.openecomp.sdc.api.consumer.IDistributionStatusMessage; +import org.openecomp.sdc.utils.DistributionStatusEnum; + +public class DistributionStatusMsg implements IDistributionStatusMessage { + private DistributionStatusEnum status; + private String distributionId; + private String consumerId; + private String artifactUrl; + + /** + * Creates a new DistributionStatusMsg instance. + * + * @param status - The distribution status to be reported. + * @param distributionId - The identifier of the distribution who's status is being rported on. + * @param consumerId - Identifier of the consumer associated with the distribution. + * @param artifactUrl - Resource identifier for the artifact. + */ + public DistributionStatusMsg(DistributionStatusEnum status, + String distributionId, + String consumerId, + String artifactUrl) { + this.status = status; + this.distributionId = distributionId; + this.consumerId = consumerId; + this.artifactUrl = artifactUrl; + } + + @Override + public long getTimestamp() { + long currentTimeMillis = System.currentTimeMillis(); + return currentTimeMillis; + } + + @Override + public DistributionStatusEnum getStatus() { + return status; + } + + @Override + public String getDistributionID() { + return distributionId; + } + + @Override + public String getConsumerID() { + return consumerId; + } + + @Override + public String getArtifactURL() { + return artifactUrl; + } +} diff --git a/src/main/java/org/openecomp/modelloader/notification/EventCallback.java b/src/main/java/org/openecomp/modelloader/notification/EventCallback.java index 3b32315..8634741 100644 --- a/src/main/java/org/openecomp/modelloader/notification/EventCallback.java +++ b/src/main/java/org/openecomp/modelloader/notification/EventCallback.java @@ -1,286 +1,294 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.notification; - -import org.openecomp.sdc.api.IDistributionClient; -import org.openecomp.sdc.api.consumer.IDistributionStatusMessage; -import org.openecomp.sdc.api.consumer.INotificationCallback; -import org.openecomp.sdc.api.notification.IArtifactInfo; -import org.openecomp.sdc.api.notification.INotificationData; -import org.openecomp.sdc.api.notification.IResourceInstance; -import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; -import org.openecomp.sdc.api.results.IDistributionClientResult; -import org.openecomp.sdc.utils.ArtifactTypeEnum; -import org.openecomp.sdc.utils.DistributionActionResultEnum; -import org.openecomp.sdc.utils.DistributionStatusEnum; - -import org.openecomp.cl.api.Logger; -import org.openecomp.cl.eelf.LoggerFactory; -import org.openecomp.cl.mdc.MdcContext; -import org.openecomp.cl.mdc.MdcOverride; -import org.openecomp.modelloader.config.ModelLoaderConfig; -import org.openecomp.modelloader.entity.Artifact; -import org.openecomp.modelloader.entity.catalog.VnfCatalogArtifact; -import org.openecomp.modelloader.entity.catalog.VnfCatalogArtifactHandler; -import org.openecomp.modelloader.entity.model.ModelArtifactHandler; -import org.openecomp.modelloader.entity.model.ModelArtifactParser; -import org.openecomp.modelloader.service.ModelLoaderMsgs; -import org.slf4j.MDC; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; - -public class EventCallback implements INotificationCallback { - - private IDistributionClient client; - private ModelLoaderConfig config; - private static Logger logger = LoggerFactory.getInstance() - .getLogger(EventCallback.class.getName()); - private static Logger auditLogger = LoggerFactory.getInstance() - .getAuditLogger(EventCallback.class.getName()); - private static Logger metricsLogger = LoggerFactory.getInstance() - .getMetricsLogger(EventCallback.class.getName()); - - private static SimpleDateFormat dateFormatter = new SimpleDateFormat( - "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); - - public EventCallback(IDistributionClient client, ModelLoaderConfig config) { - this.client = client; - this.config = config; - } - - @Override - public void activateCallback(INotificationData data) { - // Init MDC - MdcContext.initialize(data.getDistributionID(), "ModelLoader", "", "Event-Bus", ""); - - logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, - "Received distribution " + data.getDistributionID()); - - boolean success = true; - List artifacts = getArtifacts(data); - List modelArtifacts = new ArrayList(); - List catalogArtifacts = new ArrayList(); - ModelArtifactParser modelArtParser = new ModelArtifactParser(); - - for (IArtifactInfo artifact : artifacts) { - // Grab the current time so we can measure the download time for the - // metrics log - long startTimeInMs = System.currentTimeMillis(); - MdcOverride override = new MdcOverride(); - override.addAttribute(MdcContext.MDC_START_TIME, dateFormatter.format(startTimeInMs)); - - // Download Artifact - IDistributionClientDownloadResult downloadResult = client.download(artifact); - - // Generate metrics log - metricsLogger.info(ModelLoaderMsgs.DOWNLOAD_COMPLETE, null, override, - artifact.getArtifactName(), downloadResult.getDistributionActionResult().toString()); - - if (downloadResult.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { - publishDownloadFailure(data, artifact, downloadResult.getDistributionMessageResult()); - success = false; - break; - } - - logger.debug("Artifact: " + artifact.getArtifactName() + " Payload:\n" + new String(downloadResult.getArtifactPayload())); - - publishDownloadSuccess(data, artifact, downloadResult); - - if ((artifact.getArtifactType() - .compareToIgnoreCase(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.toString()) == 0) - || (artifact.getArtifactType() - .compareToIgnoreCase(ArtifactTypeEnum.MODEL_QUERY_SPEC.toString()) == 0)) { - modelArtifacts.addAll(modelArtParser.parse(downloadResult.getArtifactPayload(), - downloadResult.getArtifactName())); - } else if (artifact.getArtifactType() - .compareToIgnoreCase(ArtifactTypeEnum.VNF_CATALOG.toString()) == 0) { - catalogArtifacts - .add(new VnfCatalogArtifact(new String(downloadResult.getArtifactPayload()))); - } - } - - String statusString = "SUCCESS"; - if (success) { - ModelArtifactHandler modelHandler = new ModelArtifactHandler(config); - boolean modelDeploySuccess = modelHandler.pushArtifacts(modelArtifacts, - data.getDistributionID()); - - VnfCatalogArtifactHandler catalogHandler = new VnfCatalogArtifactHandler(config); - boolean catalogDeploySuccess = catalogHandler.pushArtifacts(catalogArtifacts, - data.getDistributionID()); - - for (IArtifactInfo artifact : artifacts) { - if ((artifact.getArtifactType() - .compareToIgnoreCase(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.toString()) == 0) - || (artifact.getArtifactType() - .compareToIgnoreCase(ArtifactTypeEnum.MODEL_QUERY_SPEC.toString()) == 0)) { - if (modelDeploySuccess) { - publishDeploySuccess(data, artifact); - } else { - publishDeployFailure(data, artifact); - statusString = "FAILURE"; - } - } else if (artifact.getArtifactType() - .compareToIgnoreCase(ArtifactTypeEnum.VNF_CATALOG.toString()) == 0) { - if (catalogDeploySuccess) { - publishDeploySuccess(data, artifact); - } else { - publishDeployFailure(data, artifact); - statusString = "FAILURE"; - } - } - } - } - - auditLogger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, - "Processed distribution " + data.getDistributionID() + " (" + statusString + ")"); - MDC.clear(); - } - - private List getArtifacts(INotificationData data) { - List artifacts = new ArrayList(); - List resources = data.getResources(); - - if (data.getServiceArtifacts() != null) { - artifacts.addAll(data.getServiceArtifacts()); - } - - if (resources != null) { - for (IResourceInstance resource : resources) { - if (resource.getArtifacts() != null) { - artifacts.addAll(resource.getArtifacts()); - } - } - } - - return artifacts; - } - - private void publishDownloadFailure(INotificationData data, IArtifactInfo artifact, - String errorMessage) { - // Grab the current time so we can measure the download time for the metrics - // log - long startTimeInMs = System.currentTimeMillis(); - MdcOverride override = new MdcOverride(); - override.addAttribute(MdcContext.MDC_START_TIME, dateFormatter.format(startTimeInMs)); - - IDistributionClientResult sendDownloadStatus = client.sendDownloadStatus( - buildStatusMessage(client, data, artifact, DistributionStatusEnum.DOWNLOAD_ERROR)); - metricsLogger.info(ModelLoaderMsgs.EVENT_PUBLISHED, null, override, "download failure", - artifact.getArtifactName(), sendDownloadStatus.getDistributionActionResult().toString()); - - if (sendDownloadStatus.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { - logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, - "Failed to publish download failure status: " - + sendDownloadStatus.getDistributionMessageResult()); - } - - logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, - "Failed to download artifact " + artifact.getArtifactName() + ": " + errorMessage); - } - - private void publishDownloadSuccess(INotificationData data, IArtifactInfo artifact, - IDistributionClientDownloadResult downloadResult) { - // Grab the current time so we can measure the download time for the metrics - // log - long startTimeInMs = System.currentTimeMillis(); - MdcOverride override = new MdcOverride(); - override.addAttribute(MdcContext.MDC_START_TIME, dateFormatter.format(startTimeInMs)); - - IDistributionClientResult sendDownloadStatus = client.sendDownloadStatus( - buildStatusMessage(client, data, artifact, DistributionStatusEnum.DOWNLOAD_OK)); - metricsLogger.info(ModelLoaderMsgs.EVENT_PUBLISHED, null, override, "download success", - artifact.getArtifactName(), sendDownloadStatus.getDistributionActionResult().toString()); - - logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, - "Downloaded artifact: " + artifact.getArtifactName()); - - if (sendDownloadStatus.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { - logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, - "Failed to publish download success status: " - + sendDownloadStatus.getDistributionMessageResult()); - } - - if (logger.isDebugEnabled()) { - StringBuilder sb = new StringBuilder(); - sb.append("Downloaded artifact:\n"); - sb.append("ArtInfo_Art_Name: " + artifact.getArtifactName()); - sb.append("\nArtInfo_Art_description: " + artifact.getArtifactDescription()); - sb.append("\nArtInfo_Art_CheckSum: " + artifact.getArtifactChecksum()); - sb.append("\nArtInfo_Art_Url: " + artifact.getArtifactURL()); - sb.append("\nArtInfo_Art_Type: " + artifact.getArtifactType()); - sb.append("\nArtInfo_Serv_description: " + data.getServiceDescription()); - sb.append("\nArtInfo_Serv_Name: " + data.getServiceName()); - sb.append("\nGet_serviceVersion: " + data.getServiceVersion()); - sb.append("\nGet_Service_UUID: " + data.getServiceUUID()); - sb.append("\nArtInfo_DistributionId: " + data.getDistributionID()); - logger.debug(sb.toString()); - } - } - - private void publishDeployFailure(INotificationData data, IArtifactInfo artifact) { - // Grab the current time so we can measure the download time for the metrics - // log - long startTimeInMs = System.currentTimeMillis(); - MdcOverride override = new MdcOverride(); - override.addAttribute(MdcContext.MDC_START_TIME, dateFormatter.format(startTimeInMs)); - - IDistributionClientResult sendStatus = client.sendDeploymentStatus( - buildStatusMessage(client, data, artifact, DistributionStatusEnum.DEPLOY_ERROR)); - metricsLogger.info(ModelLoaderMsgs.EVENT_PUBLISHED, null, override, "deploy failure", - artifact.getArtifactName(), sendStatus.getDistributionActionResult().toString()); - - if (sendStatus.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { - logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, - "Failed to publish deploy failure status: " + sendStatus.getDistributionMessageResult()); - } - } - - private void publishDeploySuccess(INotificationData data, IArtifactInfo artifact) { - // Grab the current time so we can measure the download time for the metrics - // log - long startTimeInMs = System.currentTimeMillis(); - MdcOverride override = new MdcOverride(); - override.addAttribute(MdcContext.MDC_START_TIME, dateFormatter.format(startTimeInMs)); - - IDistributionClientResult sendStatus = client.sendDownloadStatus( - buildStatusMessage(client, data, artifact, DistributionStatusEnum.DEPLOY_OK)); - metricsLogger.info(ModelLoaderMsgs.EVENT_PUBLISHED, null, override, "deploy success", - artifact.getArtifactName(), sendStatus.getDistributionActionResult().toString()); - - if (sendStatus.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { - logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, - "Failed to publish deploy success status: " + sendStatus.getDistributionMessageResult()); - } - } - - private IDistributionStatusMessage buildStatusMessage(IDistributionClient client, - INotificationData data, IArtifactInfo artifact, DistributionStatusEnum status) { - IDistributionStatusMessage statusMessage = new DistributionStatusMsg(status, - data.getDistributionID(), client.getConfiguration().getConsumerID(), - artifact.getArtifactURL()); - - return statusMessage; - } - -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.notification; + +import org.openecomp.sdc.api.IDistributionClient; +import org.openecomp.sdc.api.consumer.IDistributionStatusMessage; +import org.openecomp.sdc.api.consumer.INotificationCallback; +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.notification.IResourceInstance; +import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; +import org.openecomp.sdc.api.results.IDistributionClientResult; +import org.openecomp.sdc.utils.ArtifactTypeEnum; +import org.openecomp.sdc.utils.DistributionActionResultEnum; +import org.openecomp.sdc.utils.DistributionStatusEnum; + +import org.openecomp.cl.api.Logger; +import org.openecomp.cl.eelf.LoggerFactory; +import org.openecomp.cl.mdc.MdcContext; +import org.openecomp.cl.mdc.MdcOverride; +import org.openecomp.modelloader.config.ModelLoaderConfig; +import org.openecomp.modelloader.entity.Artifact; +import org.openecomp.modelloader.entity.catalog.VnfCatalogArtifact; +import org.openecomp.modelloader.entity.catalog.VnfCatalogArtifactHandler; +import org.openecomp.modelloader.entity.model.ModelArtifactHandler; +import org.openecomp.modelloader.entity.model.ModelArtifactParser; +import org.openecomp.modelloader.service.ModelLoaderMsgs; +import org.slf4j.MDC; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; + +public class EventCallback implements INotificationCallback { + + private IDistributionClient client; + private ModelLoaderConfig config; + private static Logger logger = LoggerFactory.getInstance() + .getLogger(EventCallback.class.getName()); + private static Logger auditLogger = LoggerFactory.getInstance() + .getAuditLogger(EventCallback.class.getName()); + private static Logger metricsLogger = LoggerFactory.getInstance() + .getMetricsLogger(EventCallback.class.getName()); + + private static SimpleDateFormat dateFormatter = new SimpleDateFormat( + "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); + + public EventCallback(IDistributionClient client, ModelLoaderConfig config) { + this.client = client; + this.config = config; + } + + @Override + public void activateCallback(INotificationData data) { + // Init MDC + MdcContext.initialize(data.getDistributionID(), "ModelLoader", "", "Event-Bus", ""); + + logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, + "Received distribution " + data.getDistributionID()); + + boolean success = true; + List artifacts = getArtifacts(data); + List modelArtifacts = new ArrayList(); + List catalogArtifacts = new ArrayList(); + ModelArtifactParser modelArtParser = new ModelArtifactParser(); + + for (IArtifactInfo artifact : artifacts) { + // Grab the current time so we can measure the download time for the + // metrics log + long startTimeInMs = System.currentTimeMillis(); + MdcOverride override = new MdcOverride(); + override.addAttribute(MdcContext.MDC_START_TIME, dateFormatter.format(startTimeInMs)); + + // Download Artifact + IDistributionClientDownloadResult downloadResult = client.download(artifact); + + // Generate metrics log + metricsLogger.info(ModelLoaderMsgs.DOWNLOAD_COMPLETE, null, override, + artifact.getArtifactName(), downloadResult.getDistributionActionResult().toString()); + + if (downloadResult.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { + publishDownloadFailure(data, artifact, downloadResult.getDistributionMessageResult()); + success = false; + break; + } + + logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, + "Downloaded artifact: " + artifact.getArtifactName() + " Payload:\n" + new String(downloadResult.getArtifactPayload())); + + publishDownloadSuccess(data, artifact, downloadResult); + + if ((artifact.getArtifactType() + .compareToIgnoreCase(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.toString()) == 0) + || (artifact.getArtifactType() + .compareToIgnoreCase(ArtifactTypeEnum.MODEL_QUERY_SPEC.toString()) == 0)) { + List parsedArtifacts = modelArtParser.parse(downloadResult.getArtifactPayload(), downloadResult.getArtifactName()); + if (parsedArtifacts != null && !parsedArtifacts.isEmpty()) { + modelArtifacts.addAll(parsedArtifacts); + } else { + success = false; + publishDeployFailure(data, artifact); + break; + } + } else if (artifact.getArtifactType() + .compareToIgnoreCase(ArtifactTypeEnum.VNF_CATALOG.toString()) == 0) { + catalogArtifacts + .add(new VnfCatalogArtifact(new String(downloadResult.getArtifactPayload()))); + } + } + + String statusString = "SUCCESS"; + if (success) { + ModelArtifactHandler modelHandler = new ModelArtifactHandler(config); + boolean modelDeploySuccess = modelHandler.pushArtifacts(modelArtifacts, + data.getDistributionID()); + + VnfCatalogArtifactHandler catalogHandler = new VnfCatalogArtifactHandler(config); + boolean catalogDeploySuccess = catalogHandler.pushArtifacts(catalogArtifacts, + data.getDistributionID()); + + for (IArtifactInfo artifact : artifacts) { + if ((artifact.getArtifactType() + .compareToIgnoreCase(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.toString()) == 0) + || (artifact.getArtifactType() + .compareToIgnoreCase(ArtifactTypeEnum.MODEL_QUERY_SPEC.toString()) == 0)) { + if (modelDeploySuccess) { + publishDeploySuccess(data, artifact); + } else { + publishDeployFailure(data, artifact); + statusString = "FAILURE"; + } + } else if (artifact.getArtifactType() + .compareToIgnoreCase(ArtifactTypeEnum.VNF_CATALOG.toString()) == 0) { + if (catalogDeploySuccess) { + publishDeploySuccess(data, artifact); + } else { + publishDeployFailure(data, artifact); + statusString = "FAILURE"; + } + } + } + } else { + statusString = "FAILURE"; + } + + auditLogger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, + "Processed distribution " + data.getDistributionID() + " (" + statusString + ")"); + MDC.clear(); + } + + private List getArtifacts(INotificationData data) { + List artifacts = new ArrayList(); + List resources = data.getResources(); + + if (data.getServiceArtifacts() != null) { + artifacts.addAll(data.getServiceArtifacts()); + } + + if (resources != null) { + for (IResourceInstance resource : resources) { + if (resource.getArtifacts() != null) { + artifacts.addAll(resource.getArtifacts()); + } + } + } + + return artifacts; + } + + private void publishDownloadFailure(INotificationData data, IArtifactInfo artifact, + String errorMessage) { + // Grab the current time so we can measure the download time for the metrics + // log + long startTimeInMs = System.currentTimeMillis(); + MdcOverride override = new MdcOverride(); + override.addAttribute(MdcContext.MDC_START_TIME, dateFormatter.format(startTimeInMs)); + + IDistributionClientResult sendDownloadStatus = client.sendDownloadStatus( + buildStatusMessage(client, data, artifact, DistributionStatusEnum.DOWNLOAD_ERROR)); + metricsLogger.info(ModelLoaderMsgs.EVENT_PUBLISHED, null, override, "download failure", + artifact.getArtifactName(), sendDownloadStatus.getDistributionActionResult().toString()); + + if (sendDownloadStatus.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { + logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, + "Failed to publish download failure status: " + + sendDownloadStatus.getDistributionMessageResult()); + } + + logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, + "Failed to download artifact " + artifact.getArtifactName() + ": " + errorMessage); + } + + private void publishDownloadSuccess(INotificationData data, IArtifactInfo artifact, + IDistributionClientDownloadResult downloadResult) { + // Grab the current time so we can measure the download time for the metrics + // log + long startTimeInMs = System.currentTimeMillis(); + MdcOverride override = new MdcOverride(); + override.addAttribute(MdcContext.MDC_START_TIME, dateFormatter.format(startTimeInMs)); + + IDistributionClientResult sendDownloadStatus = client.sendDownloadStatus( + buildStatusMessage(client, data, artifact, DistributionStatusEnum.DOWNLOAD_OK)); + metricsLogger.info(ModelLoaderMsgs.EVENT_PUBLISHED, null, override, "download success", + artifact.getArtifactName(), sendDownloadStatus.getDistributionActionResult().toString()); + + if (sendDownloadStatus.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { + logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, + "Failed to publish download success status: " + + sendDownloadStatus.getDistributionMessageResult()); + } + + if (logger.isDebugEnabled()) { + StringBuilder sb = new StringBuilder(); + sb.append("Downloaded artifact:\n"); + sb.append("ArtInfo_Art_Name: " + artifact.getArtifactName()); + sb.append("\nArtInfo_Art_description: " + artifact.getArtifactDescription()); + sb.append("\nArtInfo_Art_CheckSum: " + artifact.getArtifactChecksum()); + sb.append("\nArtInfo_Art_Url: " + artifact.getArtifactURL()); + sb.append("\nArtInfo_Art_Type: " + artifact.getArtifactType()); + sb.append("\nArtInfo_Serv_description: " + data.getServiceDescription()); + sb.append("\nArtInfo_Serv_Name: " + data.getServiceName()); + sb.append("\nGet_serviceVersion: " + data.getServiceVersion()); + sb.append("\nGet_Service_UUID: " + data.getServiceUUID()); + sb.append("\nArtInfo_DistributionId: " + data.getDistributionID()); + logger.debug(sb.toString()); + } + } + + private void publishDeployFailure(INotificationData data, IArtifactInfo artifact) { + // Grab the current time so we can measure the download time for the metrics + // log + long startTimeInMs = System.currentTimeMillis(); + MdcOverride override = new MdcOverride(); + override.addAttribute(MdcContext.MDC_START_TIME, dateFormatter.format(startTimeInMs)); + + IDistributionClientResult sendStatus = client.sendDeploymentStatus( + buildStatusMessage(client, data, artifact, DistributionStatusEnum.DEPLOY_ERROR)); + metricsLogger.info(ModelLoaderMsgs.EVENT_PUBLISHED, null, override, "deploy failure", + artifact.getArtifactName(), sendStatus.getDistributionActionResult().toString()); + + if (sendStatus.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { + logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, + "Failed to publish deploy failure status: " + sendStatus.getDistributionMessageResult()); + } + } + + private void publishDeploySuccess(INotificationData data, IArtifactInfo artifact) { + // Grab the current time so we can measure the download time for the metrics + // log + long startTimeInMs = System.currentTimeMillis(); + MdcOverride override = new MdcOverride(); + override.addAttribute(MdcContext.MDC_START_TIME, dateFormatter.format(startTimeInMs)); + + IDistributionClientResult sendStatus = client.sendDownloadStatus( + buildStatusMessage(client, data, artifact, DistributionStatusEnum.DEPLOY_OK)); + metricsLogger.info(ModelLoaderMsgs.EVENT_PUBLISHED, null, override, "deploy success", + artifact.getArtifactName(), sendStatus.getDistributionActionResult().toString()); + + if (sendStatus.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { + logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, + "Failed to publish deploy success status: " + sendStatus.getDistributionMessageResult()); + } + } + + private IDistributionStatusMessage buildStatusMessage(IDistributionClient client, + INotificationData data, IArtifactInfo artifact, DistributionStatusEnum status) { + IDistributionStatusMessage statusMessage = new DistributionStatusMsg(status, + data.getDistributionID(), client.getConfiguration().getConsumerID(), + artifact.getArtifactURL()); + + return statusMessage; + } + +} diff --git a/src/main/java/org/openecomp/modelloader/restclient/AaiRestClient.java b/src/main/java/org/openecomp/modelloader/restclient/AaiRestClient.java index e13bdbd..d4ee738 100644 --- a/src/main/java/org/openecomp/modelloader/restclient/AaiRestClient.java +++ b/src/main/java/org/openecomp/modelloader/restclient/AaiRestClient.java @@ -1,400 +1,402 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.restclient; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.api.client.filter.LoggingFilter; -import com.sun.jersey.client.urlconnection.HTTPSProperties; -import org.openecomp.cl.api.LogFields; -import org.openecomp.cl.api.LogLine; -import org.openecomp.cl.api.Logger; -import org.openecomp.cl.eelf.LoggerFactory; -import org.openecomp.cl.mdc.MdcContext; -import org.openecomp.cl.mdc.MdcOverride; -import org.openecomp.modelloader.config.ModelLoaderConfig; -import org.openecomp.modelloader.service.ModelLoaderMsgs; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -import java.io.ByteArrayOutputStream; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.io.StringReader; -import java.security.GeneralSecurityException; -import java.security.KeyStore; -import java.security.cert.X509Certificate; -import java.text.SimpleDateFormat; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; -import javax.ws.rs.core.Response; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -public class AaiRestClient { - public enum MimeType { - XML("application/xml"), JSON("application/json"); - - private String httpType; - - MimeType(String httpType) { - this.httpType = httpType; - } - - String getHttpHeaderType() { - return httpType; - } - } - - private static String HEADER_TRANS_ID = "X-TransactionId"; - private static String HEADER_FROM_APP_ID = "X-FromAppId"; - private static String HEADER_AUTHORIZATION = "Authorization"; - private static String ML_APP_NAME = "ModelLoader"; - private static String RESOURCE_VERSION_PARAM = "resource-version"; - - private static SimpleDateFormat dateFormatter = new SimpleDateFormat( - "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); - - private static Logger logger = LoggerFactory.getInstance() - .getLogger(AaiRestClient.class.getName()); - private static Logger metricsLogger = LoggerFactory.getInstance() - .getMetricsLogger(AaiRestClient.class.getName()); - - private ModelLoaderConfig config = null; - - public AaiRestClient(ModelLoaderConfig config) { - this.config = config; - } - - /** - * Send a PUT request to the A&AI. - * - * @param url - * - the url - * @param transId - * - transaction ID - * @param payload - * - the XML or JSON payload for the request - * @param mimeType - * - the content type (XML or JSON) - * @return ClientResponse - */ - public ClientResponse putResource(String url, String payload, String transId, MimeType mimeType) { - ClientResponse result = null; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - long startTimeInMs = 0; - MdcOverride override = new MdcOverride(); - - try { - Client client = setupClient(); - - baos = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(baos); - if (logger.isDebugEnabled()) { - client.addFilter(new LoggingFilter(ps)); - } - - // Grab the current time so that we can use it for metrics purposes later. - startTimeInMs = System.currentTimeMillis(); - override.addAttribute(MdcContext.MDC_START_TIME, dateFormatter.format(startTimeInMs)); - - if (useBasicAuth()) { - result = client.resource(url).header(HEADER_TRANS_ID, transId) - .header(HEADER_FROM_APP_ID, ML_APP_NAME) - .header(HEADER_AUTHORIZATION, getAuthenticationCredentials()) - .type(mimeType.getHttpHeaderType()).put(ClientResponse.class, payload); - } else { - result = client.resource(url).header(HEADER_TRANS_ID, transId) - .header(HEADER_FROM_APP_ID, ML_APP_NAME).type(mimeType.getHttpHeaderType()) - .put(ClientResponse.class, payload); - } - } catch (Exception ex) { - logger.error(ModelLoaderMsgs.AAI_REST_REQUEST_ERROR, "PUT", url, ex.getLocalizedMessage()); - return null; - } finally { - if (logger.isDebugEnabled()) { - logger.debug(baos.toString()); - } - } - - if ((result != null) && ((result.getStatus() == Response.Status.CREATED.getStatusCode()) - || (result.getStatus() == Response.Status.OK.getStatusCode()))) { - logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_SUCCESS, "PUT", url, - Integer.toString(result.getStatus())); - metricsLogger.info(ModelLoaderMsgs.AAI_REST_REQUEST_SUCCESS, - new LogFields().setField(LogLine.DefinedFields.RESPONSE_CODE, result.getStatus()) - .setField(LogLine.DefinedFields.RESPONSE_DESCRIPTION, - result.getResponseStatus().toString()), - override, "PUT", url, Integer.toString(result.getStatus())); - } else { - // If response is not 200 OK, then additionally log the reason - String respMsg = result.getEntity(String.class); - if (respMsg == null) { - respMsg = result.getStatusInfo().getReasonPhrase(); - } - logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_UNSUCCESSFUL, "PUT", url, - Integer.toString(result.getStatus()), respMsg); - metricsLogger.info(ModelLoaderMsgs.AAI_REST_REQUEST_UNSUCCESSFUL, - new LogFields().setField(LogLine.DefinedFields.RESPONSE_CODE, result.getStatus()) - .setField(LogLine.DefinedFields.RESPONSE_DESCRIPTION, - result.getResponseStatus().toString()), - override, "PUT", url, Integer.toString(result.getStatus()), respMsg); - } - - return result; - } - - /** - * Send a DELETE request to the A&AI. - * - * @param url - * - the url - * @param resourceVersion - * - the resource-version of the model to delete - * @param transId - * - transaction ID - * @return ClientResponse - */ - public ClientResponse deleteResource(String url, String resourceVersion, String transId) { - ClientResponse result = null; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - long startTimeInMs = 0; - MdcOverride override = new MdcOverride(); - - try { - Client client = setupClient(); - - baos = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(baos); - if (logger.isDebugEnabled()) { - client.addFilter(new LoggingFilter(ps)); - } - - // Grab the current time so that we can use it for metrics purposes later. - startTimeInMs = System.currentTimeMillis(); - override.addAttribute(MdcContext.MDC_START_TIME, dateFormatter.format(startTimeInMs)); - - if (useBasicAuth()) { - result = client.resource(url).queryParam(RESOURCE_VERSION_PARAM, resourceVersion) - .header(HEADER_TRANS_ID, transId).header(HEADER_FROM_APP_ID, ML_APP_NAME) - .header(HEADER_AUTHORIZATION, getAuthenticationCredentials()) - .delete(ClientResponse.class); - } else { - result = client.resource(url).queryParam(RESOURCE_VERSION_PARAM, resourceVersion) - .header(HEADER_TRANS_ID, transId).header(HEADER_FROM_APP_ID, ML_APP_NAME) - .delete(ClientResponse.class); - } - } catch (Exception ex) { - logger.error(ModelLoaderMsgs.AAI_REST_REQUEST_ERROR, "DELETE", url, ex.getLocalizedMessage()); - return null; - } finally { - if (logger.isDebugEnabled()) { - logger.debug(baos.toString()); - } - } - - logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_SUCCESS, "DELETE", url, - Integer.toString(result.getStatus())); - metricsLogger.info(ModelLoaderMsgs.AAI_REST_REQUEST_SUCCESS, - new LogFields().setField(LogLine.DefinedFields.RESPONSE_CODE, result.getStatus()).setField( - LogLine.DefinedFields.RESPONSE_DESCRIPTION, result.getResponseStatus().toString()), - override, "DELETE", url, Integer.toString(result.getStatus())); - - return result; - } - - /** - * Send a GET request to the A&AI for a resource. - * - * @param url - * - the url to use - * @param transId - * - transaction ID - * @return ClientResponse - */ - public ClientResponse getResource(String url, String transId, MimeType mimeType) { - ClientResponse result = null; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - long startTimeInMs = 0; - MdcOverride override = new MdcOverride(); - - try { - Client client = setupClient(); - - baos = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(baos); - if (logger.isDebugEnabled()) { - client.addFilter(new LoggingFilter(ps)); - } - - // Grab the current time so that we can use it for metrics purposes later. - startTimeInMs = System.currentTimeMillis(); - override.addAttribute(MdcContext.MDC_START_TIME, dateFormatter.format(startTimeInMs)); - - if (useBasicAuth()) { - result = client.resource(url).header(HEADER_TRANS_ID, transId) - .header(HEADER_FROM_APP_ID, ML_APP_NAME).accept(mimeType.getHttpHeaderType()) - .header(HEADER_AUTHORIZATION, getAuthenticationCredentials()).get(ClientResponse.class); - } else { - result = client.resource(url).header(HEADER_TRANS_ID, transId) - .header(HEADER_FROM_APP_ID, ML_APP_NAME).accept(mimeType.getHttpHeaderType()) - .get(ClientResponse.class); - - } - } catch (Exception ex) { - logger.error(ModelLoaderMsgs.AAI_REST_REQUEST_ERROR, "GET", url, ex.getLocalizedMessage()); - return null; - } finally { - if (logger.isDebugEnabled()) { - logger.debug(baos.toString()); - } - } - - logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_SUCCESS, "GET", url, - Integer.toString(result.getStatus())); - metricsLogger.info(ModelLoaderMsgs.AAI_REST_REQUEST_SUCCESS, - new LogFields().setField(LogLine.DefinedFields.RESPONSE_CODE, result.getStatus()).setField( - LogLine.DefinedFields.RESPONSE_DESCRIPTION, result.getResponseStatus().toString()), - override, "GET", url, Integer.toString(result.getStatus())); - - return result; - } - - /** - * Does a GET on a resource to retrieve the resource version, and then DELETE - * that version. - * - * @param url - * - the url - * @param transId - * - transaction ID - * @return ClientResponse - */ - public ClientResponse getAndDeleteResource(String url, String transId) { - // First, GET the model - ClientResponse getResponse = getResource(url, transId, MimeType.XML); - if ((getResponse == null) || (getResponse.getStatus() != Response.Status.OK.getStatusCode())) { - return getResponse; - } - - // Delete the model using the resource version in the response - String resVersion = null; - try { - resVersion = getResourceVersion(getResponse); - } catch (Exception e) { - logger.error(ModelLoaderMsgs.AAI_REST_REQUEST_ERROR, "GET", url, e.getLocalizedMessage()); - return null; - } - - return deleteResource(url, resVersion, transId); - } - - private Client setupClient() throws IOException, GeneralSecurityException { - ClientConfig clientConfig = new DefaultClientConfig(); - - HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { - @Override - public boolean verify(String string, SSLSession ssls) { - return true; - } - }); - - // Create a trust manager that does not validate certificate chains - TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { - @Override - public X509Certificate[] getAcceptedIssuers() { - return null; - } - - @Override - public void checkClientTrusted(X509Certificate[] certs, String authType) {} - - @Override - public void checkServerTrusted(X509Certificate[] certs, String authType) {} - } }; - - SSLContext ctx = SSLContext.getInstance("TLS"); - KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); - FileInputStream fin = new FileInputStream(config.getAaiKeyStorePath()); - KeyStore ks = KeyStore.getInstance("PKCS12"); - char[] pwd = config.getAaiKeyStorePassword().toCharArray(); - ks.load(fin, pwd); - kmf.init(ks, pwd); - - ctx.init(kmf.getKeyManagers(), trustAllCerts, null); - clientConfig.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, - new HTTPSProperties(new HostnameVerifier() { - @Override - public boolean verify(String theString, SSLSession sslSession) { - return true; - } - }, ctx)); - - Client client = Client.create(clientConfig); - - return client; - } - - private String getResourceVersion(ClientResponse response) - throws ParserConfigurationException, SAXException, IOException { - String respData = response.getEntity(String.class); - - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - InputSource is = new InputSource(new StringReader(respData)); - Document doc = builder.parse(is); - - NodeList nodeList = doc.getDocumentElement().getChildNodes(); - for (int i = 0; i < nodeList.getLength(); i++) { - Node currentNode = nodeList.item(i); - if (currentNode.getNodeName().equals(RESOURCE_VERSION_PARAM)) { - return currentNode.getTextContent(); - } - } - - return null; - } - - private String getAuthenticationCredentials() { - - String usernameAndPassword = config.getAaiAuthenticationUser() + ":" - + config.getAaiAuthenticationPassword(); - return "Basic " + java.util.Base64.getEncoder().encodeToString(usernameAndPassword.getBytes()); - } - - public boolean useBasicAuth() { - return (config.getAaiAuthenticationUser() != null) - && (config.getAaiAuthenticationPassword() != null); - } -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.restclient; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.api.client.filter.LoggingFilter; +import com.sun.jersey.client.urlconnection.HTTPSProperties; +import org.openecomp.cl.api.LogFields; +import org.openecomp.cl.api.LogLine; +import org.openecomp.cl.api.Logger; +import org.openecomp.cl.eelf.LoggerFactory; +import org.openecomp.cl.mdc.MdcContext; +import org.openecomp.cl.mdc.MdcOverride; +import org.openecomp.modelloader.config.ModelLoaderConfig; +import org.openecomp.modelloader.service.ModelLoaderMsgs; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.io.StringReader; +import java.security.GeneralSecurityException; +import java.security.KeyStore; +import java.security.cert.X509Certificate; +import java.text.SimpleDateFormat; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import javax.ws.rs.core.Response; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +public class AaiRestClient { + public enum MimeType { + XML("application/xml"), JSON("application/json"); + + private String httpType; + + MimeType(String httpType) { + this.httpType = httpType; + } + + String getHttpHeaderType() { + return httpType; + } + } + + private static String HEADER_TRANS_ID = "X-TransactionId"; + private static String HEADER_FROM_APP_ID = "X-FromAppId"; + private static String HEADER_AUTHORIZATION = "Authorization"; + private static String ML_APP_NAME = "ModelLoader"; + private static String RESOURCE_VERSION_PARAM = "resource-version"; + + private static SimpleDateFormat dateFormatter = new SimpleDateFormat( + "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); + + private static Logger logger = LoggerFactory.getInstance() + .getLogger(AaiRestClient.class.getName()); + private static Logger metricsLogger = LoggerFactory.getInstance() + .getMetricsLogger(AaiRestClient.class.getName()); + + private ModelLoaderConfig config = null; + + public AaiRestClient(ModelLoaderConfig config) { + this.config = config; + } + + /** + * Send a PUT request to the A&AI. + * + * @param url + * - the url + * @param transId + * - transaction ID + * @param payload + * - the XML or JSON payload for the request + * @param mimeType + * - the content type (XML or JSON) + * @return ClientResponse + */ + public ClientResponse putResource(String url, String payload, String transId, MimeType mimeType) { + ClientResponse result = null; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + long startTimeInMs = 0; + MdcOverride override = new MdcOverride(); + + try { + Client client = setupClient(); + + baos = new ByteArrayOutputStream(); + PrintStream ps = new PrintStream(baos); + if (logger.isDebugEnabled()) { + client.addFilter(new LoggingFilter(ps)); + } + + // Grab the current time so that we can use it for metrics purposes later. + startTimeInMs = System.currentTimeMillis(); + override.addAttribute(MdcContext.MDC_START_TIME, dateFormatter.format(startTimeInMs)); + + if (useBasicAuth()) { + result = client.resource(url).header(HEADER_TRANS_ID, transId) + .header(HEADER_FROM_APP_ID, ML_APP_NAME) + .header(HEADER_AUTHORIZATION, getAuthenticationCredentials()) + .type(mimeType.getHttpHeaderType()).put(ClientResponse.class, payload); + } else { + result = client.resource(url).header(HEADER_TRANS_ID, transId) + .header(HEADER_FROM_APP_ID, ML_APP_NAME).type(mimeType.getHttpHeaderType()) + .put(ClientResponse.class, payload); + } + } catch (Exception ex) { + logger.error(ModelLoaderMsgs.AAI_REST_REQUEST_ERROR, "PUT", url, ex.getLocalizedMessage()); + return null; + } finally { + if (logger.isDebugEnabled()) { + logger.debug(baos.toString()); + } + } + + if ((result != null) && ((result.getStatus() == Response.Status.CREATED.getStatusCode()) + || (result.getStatus() == Response.Status.OK.getStatusCode()))) { + logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_SUCCESS, "PUT", url, + Integer.toString(result.getStatus())); + metricsLogger.info(ModelLoaderMsgs.AAI_REST_REQUEST_SUCCESS, + new LogFields().setField(LogLine.DefinedFields.RESPONSE_CODE, result.getStatus()) + .setField(LogLine.DefinedFields.RESPONSE_DESCRIPTION, + result.getResponseStatus().toString()), + override, "PUT", url, Integer.toString(result.getStatus())); + } else { + // If response is not 200 OK, then additionally log the reason + String respMsg = result.getEntity(String.class); + if (respMsg == null) { + respMsg = result.getStatusInfo().getReasonPhrase(); + } + logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_UNSUCCESSFUL, "PUT", url, + Integer.toString(result.getStatus()), respMsg); + metricsLogger.info(ModelLoaderMsgs.AAI_REST_REQUEST_UNSUCCESSFUL, + new LogFields().setField(LogLine.DefinedFields.RESPONSE_CODE, result.getStatus()) + .setField(LogLine.DefinedFields.RESPONSE_DESCRIPTION, + result.getResponseStatus().toString()), + override, "PUT", url, Integer.toString(result.getStatus()), respMsg); + } + + return result; + } + + /** + * Send a DELETE request to the A&AI. + * + * @param url + * - the url + * @param resourceVersion + * - the resource-version of the model to delete + * @param transId + * - transaction ID + * @return ClientResponse + */ + public ClientResponse deleteResource(String url, String resourceVersion, String transId) { + ClientResponse result = null; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + long startTimeInMs = 0; + MdcOverride override = new MdcOverride(); + + try { + Client client = setupClient(); + + baos = new ByteArrayOutputStream(); + PrintStream ps = new PrintStream(baos); + if (logger.isDebugEnabled()) { + client.addFilter(new LoggingFilter(ps)); + } + + // Grab the current time so that we can use it for metrics purposes later. + startTimeInMs = System.currentTimeMillis(); + override.addAttribute(MdcContext.MDC_START_TIME, dateFormatter.format(startTimeInMs)); + + if (useBasicAuth()) { + result = client.resource(url).queryParam(RESOURCE_VERSION_PARAM, resourceVersion) + .header(HEADER_TRANS_ID, transId).header(HEADER_FROM_APP_ID, ML_APP_NAME) + .header(HEADER_AUTHORIZATION, getAuthenticationCredentials()) + .delete(ClientResponse.class); + } else { + result = client.resource(url).queryParam(RESOURCE_VERSION_PARAM, resourceVersion) + .header(HEADER_TRANS_ID, transId).header(HEADER_FROM_APP_ID, ML_APP_NAME) + .delete(ClientResponse.class); + } + } catch (Exception ex) { + logger.error(ModelLoaderMsgs.AAI_REST_REQUEST_ERROR, "DELETE", url, ex.getLocalizedMessage()); + return null; + } finally { + if (logger.isDebugEnabled()) { + logger.debug(baos.toString()); + } + } + + logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_SUCCESS, "DELETE", url, + Integer.toString(result.getStatus())); + metricsLogger.info(ModelLoaderMsgs.AAI_REST_REQUEST_SUCCESS, + new LogFields().setField(LogLine.DefinedFields.RESPONSE_CODE, result.getStatus()).setField( + LogLine.DefinedFields.RESPONSE_DESCRIPTION, result.getResponseStatus().toString()), + override, "DELETE", url, Integer.toString(result.getStatus())); + + return result; + } + + /** + * Send a GET request to the A&AI for a resource. + * + * @param url + * - the url to use + * @param transId + * - transaction ID + * @return ClientResponse + */ + public ClientResponse getResource(String url, String transId, MimeType mimeType) { + ClientResponse result = null; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + long startTimeInMs = 0; + MdcOverride override = new MdcOverride(); + + try { + Client client = setupClient(); + + baos = new ByteArrayOutputStream(); + PrintStream ps = new PrintStream(baos); + if (logger.isDebugEnabled()) { + client.addFilter(new LoggingFilter(ps)); + } + + // Grab the current time so that we can use it for metrics purposes later. + startTimeInMs = System.currentTimeMillis(); + override.addAttribute(MdcContext.MDC_START_TIME, dateFormatter.format(startTimeInMs)); + + if (useBasicAuth()) { + result = client.resource(url).header(HEADER_TRANS_ID, transId) + .header(HEADER_FROM_APP_ID, ML_APP_NAME).accept(mimeType.getHttpHeaderType()) + .header(HEADER_AUTHORIZATION, getAuthenticationCredentials()).get(ClientResponse.class); + } else { + result = client.resource(url).header(HEADER_TRANS_ID, transId) + .header(HEADER_FROM_APP_ID, ML_APP_NAME).accept(mimeType.getHttpHeaderType()) + .get(ClientResponse.class); + + } + } catch (Exception ex) { + logger.error(ModelLoaderMsgs.AAI_REST_REQUEST_ERROR, "GET", url, ex.getLocalizedMessage()); + return null; + } finally { + if (logger.isDebugEnabled()) { + logger.debug(baos.toString()); + } + } + + logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_SUCCESS, "GET", url, + Integer.toString(result.getStatus())); + metricsLogger.info(ModelLoaderMsgs.AAI_REST_REQUEST_SUCCESS, + new LogFields().setField(LogLine.DefinedFields.RESPONSE_CODE, result.getStatus()).setField( + LogLine.DefinedFields.RESPONSE_DESCRIPTION, result.getResponseStatus().toString()), + override, "GET", url, Integer.toString(result.getStatus())); + + return result; + } + + /** + * Does a GET on a resource to retrieve the resource version, and then DELETE + * that version. + * + * @param url + * - the url + * @param transId + * - transaction ID + * @return ClientResponse + */ + public ClientResponse getAndDeleteResource(String url, String transId) { + // First, GET the model + ClientResponse getResponse = getResource(url, transId, MimeType.XML); + if ((getResponse == null) || (getResponse.getStatus() != Response.Status.OK.getStatusCode())) { + return getResponse; + } + + // Delete the model using the resource version in the response + String resVersion = null; + try { + resVersion = getResourceVersion(getResponse); + } catch (Exception e) { + logger.error(ModelLoaderMsgs.AAI_REST_REQUEST_ERROR, "GET", url, e.getLocalizedMessage()); + return null; + } + + return deleteResource(url, resVersion, transId); + } + + private Client setupClient() throws IOException, GeneralSecurityException { + ClientConfig clientConfig = new DefaultClientConfig(); + + HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { + @Override + public boolean verify(String string, SSLSession ssls) { + return true; + } + }); + + // Create a trust manager that does not validate certificate chains + TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { + @Override + public X509Certificate[] getAcceptedIssuers() { + return null; + } + + @Override + public void checkClientTrusted(X509Certificate[] certs, String authType) {} + + @Override + public void checkServerTrusted(X509Certificate[] certs, String authType) {} + } }; + + SSLContext ctx = SSLContext.getInstance("TLS"); + KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); + FileInputStream fin = new FileInputStream(config.getAaiKeyStorePath()); + KeyStore ks = KeyStore.getInstance("PKCS12"); + char[] pwd = config.getAaiKeyStorePassword().toCharArray(); + ks.load(fin, pwd); + kmf.init(ks, pwd); + + ctx.init(kmf.getKeyManagers(), trustAllCerts, null); + clientConfig.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, + new HTTPSProperties(new HostnameVerifier() { + @Override + public boolean verify(String theString, SSLSession sslSession) { + return true; + } + }, ctx)); + + Client client = Client.create(clientConfig); + + return client; + } + + private String getResourceVersion(ClientResponse response) + throws ParserConfigurationException, SAXException, IOException { + String respData = response.getEntity(String.class); + + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + InputSource is = new InputSource(new StringReader(respData)); + Document doc = builder.parse(is); + + NodeList nodeList = doc.getDocumentElement().getChildNodes(); + for (int i = 0; i < nodeList.getLength(); i++) { + Node currentNode = nodeList.item(i); + if (currentNode.getNodeName().equals(RESOURCE_VERSION_PARAM)) { + return currentNode.getTextContent(); + } + } + + return null; + } + + private String getAuthenticationCredentials() { + + String usernameAndPassword = config.getAaiAuthenticationUser() + ":" + + config.getAaiAuthenticationPassword(); + return "Basic " + java.util.Base64.getEncoder().encodeToString(usernameAndPassword.getBytes()); + } + + public boolean useBasicAuth() { + return (config.getAaiAuthenticationUser() != null) + && (config.getAaiAuthenticationPassword() != null); + } +} diff --git a/src/main/java/org/openecomp/modelloader/service/ModelLoaderInterface.java b/src/main/java/org/openecomp/modelloader/service/ModelLoaderInterface.java index 689115e..99c5735 100644 --- a/src/main/java/org/openecomp/modelloader/service/ModelLoaderInterface.java +++ b/src/main/java/org/openecomp/modelloader/service/ModelLoaderInterface.java @@ -1,53 +1,55 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.service; - -import java.io.IOException; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; - -public interface ModelLoaderInterface { - - @GET - @Path("/loadModel/{modelid}") - public Response loadModel(@PathParam("modelid") String modelid); - - @PUT - @Path("/saveModel/{modelid}/{modelname}") - public Response saveModel(@PathParam("modelid") String modelid, - @PathParam("modelname") String modelname); - - @POST - @Consumes("application/xml") - @Produces("application/xml") - @Path("/ingestModel/{modelid}") - public Response ingestModel(@PathParam("modelid") String modelid, @Context HttpServletRequest req, - String payload) throws IOException; -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.service; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; + +public interface ModelLoaderInterface { + + @GET + @Path("/loadModel/{modelid}") + public Response loadModel(@PathParam("modelid") String modelid); + + @PUT + @Path("/saveModel/{modelid}/{modelname}") + public Response saveModel(@PathParam("modelid") String modelid, + @PathParam("modelname") String modelname); + + @POST + @Consumes("application/xml") + @Produces("application/xml") + @Path("/ingestModel/{modelid}") + public Response ingestModel(@PathParam("modelid") String modelid, @Context HttpServletRequest req, + String payload) throws IOException; +} diff --git a/src/main/java/org/openecomp/modelloader/service/ModelLoaderMsgs.java b/src/main/java/org/openecomp/modelloader/service/ModelLoaderMsgs.java index b81c541..2d3137b 100644 --- a/src/main/java/org/openecomp/modelloader/service/ModelLoaderMsgs.java +++ b/src/main/java/org/openecomp/modelloader/service/ModelLoaderMsgs.java @@ -1,102 +1,110 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.service; - -import com.att.eelf.i18n.EELFResourceManager; - -import org.openecomp.cl.eelf.LogMessageEnum; - -public enum ModelLoaderMsgs implements LogMessageEnum { - - /** - * Arguments: None. - */ - LOADING_CONFIGURATION, - - /** - * Arguments: None. - */ - STOPPING_CLIENT, - - /** - * Arguments: {0} = message. - */ - INITIALIZING, - - /** - * Arguments: {0} = reason. - */ - ASDC_CONNECTION_ERROR, - - /** - * Arguments: {0} = message. - */ - DISTRIBUTION_EVENT, - - /** - * Arguments: {0} = error message. - */ - DISTRIBUTION_EVENT_ERROR, - - /** - * Arguments: {0} = request type. - * {1} = endpoint. - * {2} = result code. - */ - AAI_REST_REQUEST_SUCCESS, - - /** - * Arguments: {0} = request type. - * {1} = endpoint. - * {2} = result code. - * {3} = result. - * message - */ - AAI_REST_REQUEST_UNSUCCESSFUL, - - /** - * Arguments: {0} = request type. - * {1} = endpoint. - * {2} = error message. - */ - AAI_REST_REQUEST_ERROR, - - /** - * Arguments: {0} = artifact name. - * {1} = result. - */ - DOWNLOAD_COMPLETE, - - /** - * Arguments: {0} = event. - * {1} = artifact name. - * {2} = result. - */ - EVENT_PUBLISHED; - - /** - * Load message bundle (ModelLoaderMsgs.properties file) - */ - static { - EELFResourceManager.loadMessageBundle("org/openecomp/modelloader/service/ModelLoaderMsgs"); - } - -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.service; + +import com.att.eelf.i18n.EELFResourceManager; + +import org.openecomp.cl.eelf.LogMessageEnum; + +public enum ModelLoaderMsgs implements LogMessageEnum { + + /** + * Arguments: None. + */ + LOADING_CONFIGURATION, + + /** + * Arguments: None. + */ + STOPPING_CLIENT, + + /** + * Arguments: {0} = message. + */ + INITIALIZING, + + /** + * Arguments: {0} = reason. + */ + ASDC_CONNECTION_ERROR, + + /** + * Arguments: {0} = message. + */ + DISTRIBUTION_EVENT, + + /** + * Arguments: {0} = error message. + */ + DISTRIBUTION_EVENT_ERROR, + + /** + * Arguments: {0} = request type. + * {1} = endpoint. + * {2} = result code. + */ + AAI_REST_REQUEST_SUCCESS, + + /** + * Arguments: {0} = request type. + * {1} = endpoint. + * {2} = result code. + * {3} = result. + * message + */ + AAI_REST_REQUEST_UNSUCCESSFUL, + + /** + * Arguments: {0} = request type. + * {1} = endpoint. + * {2} = error message. + */ + AAI_REST_REQUEST_ERROR, + + /** + * Arguments: + * {0} = artifact name + */ + ARTIFACT_PARSE_ERROR, + + /** + * Arguments: {0} = artifact name. + * {1} = result. + */ + DOWNLOAD_COMPLETE, + + /** + * Arguments: {0} = event. + * {1} = artifact name. + * {2} = result. + */ + EVENT_PUBLISHED; + + /** + * Load message bundle (ModelLoaderMsgs.properties file) + */ + static { + EELFResourceManager.loadMessageBundle("org/openecomp/modelloader/service/ModelLoaderMsgs"); + } + +} diff --git a/src/main/java/org/openecomp/modelloader/service/ModelLoaderService.java b/src/main/java/org/openecomp/modelloader/service/ModelLoaderService.java index 16aba7e..118cd18 100644 --- a/src/main/java/org/openecomp/modelloader/service/ModelLoaderService.java +++ b/src/main/java/org/openecomp/modelloader/service/ModelLoaderService.java @@ -1,174 +1,188 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.service; - -import org.openecomp.sdc.api.IDistributionClient; -import org.openecomp.sdc.api.results.IDistributionClientResult; -import org.openecomp.sdc.impl.DistributionClientFactory; -import org.openecomp.sdc.utils.DistributionActionResultEnum; - -import org.openecomp.cl.api.Logger; -import org.openecomp.cl.eelf.LoggerFactory; -import org.openecomp.modelloader.config.ModelLoaderConfig; -import org.openecomp.modelloader.entity.model.ModelArtifactHandler; -import org.openecomp.modelloader.notification.EventCallback; - -import java.io.IOException; -import java.util.Properties; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.core.Response; - -/** - * Service class in charge of managing the negotiating model loading - * capabilities between AAI and an ASDC. - */ -public class ModelLoaderService implements ModelLoaderInterface { - - protected static String CONFIG_FILE = "model-loader.properties"; - - private IDistributionClient client; - private ModelLoaderConfig config; - - static Logger logger = LoggerFactory.getInstance().getLogger(ModelLoaderService.class.getName()); - - /** - * Responsible for loading configuration files and calling initialization. - */ - @PostConstruct - protected void start() { - // Load model loader system configuration - logger.info(ModelLoaderMsgs.LOADING_CONFIGURATION); - Properties configProperties = new Properties(); - try { - configProperties.load(this.getClass().getClassLoader().getResourceAsStream(CONFIG_FILE)); - } catch (IOException e) { - String errorMsg = "Failed to load configuration: " + e.getMessage(); - logger.error(ModelLoaderMsgs.ASDC_CONNECTION_ERROR, errorMsg); - shutdown(); - } - - config = new ModelLoaderConfig(configProperties); - init(); - } - - /** - * Responsible for stopping the connection to the distribution client before - * the resource is destroyed. - */ - @PreDestroy - protected void preShutdownOperations() { - logger.info(ModelLoaderMsgs.STOPPING_CLIENT); - if (client != null) { - client.stop(); - } - } - - /** - * Responsible for loading configuration files, initializing model - * distribution clients, and starting them. - */ - protected void init() { - // Initialize distribution client - logger.debug(ModelLoaderMsgs.INITIALIZING, "Initializing distribution client..."); - client = DistributionClientFactory.createDistributionClient(); - IDistributionClientResult initResult = client.init(config, new EventCallback(client, config)); - if (initResult.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { - String errorMsg = "Failed to initialize distribution client: " - + initResult.getDistributionMessageResult(); - logger.error(ModelLoaderMsgs.ASDC_CONNECTION_ERROR, errorMsg); - shutdown(); - } - - // Start distribution client - logger.debug(ModelLoaderMsgs.INITIALIZING, "Starting distribution client..."); - IDistributionClientResult startResult = client.start(); - if (startResult.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { - String errorMsg = "Failed to start distribution client: " - + startResult.getDistributionMessageResult(); - logger.error(ModelLoaderMsgs.ASDC_CONNECTION_ERROR, errorMsg); - shutdown(); - } - - logger.debug(ModelLoaderMsgs.INITIALIZING, - "Succcessfully loaded service: " + this.getClass().getSimpleName()); - } - - /** - * Shut down the process. - */ - private void shutdown() { - preShutdownOperations(); - - // TODO: Find a better way to shut down the model loader. - try { - // Give logs time to write to file - Thread.sleep(2000); - } catch (InterruptedException e) { - // Nothing we can do at this point - } - - Runtime.getRuntime().halt(1); - } - - /** (non-Javadoc) - * @see org.openecomp.modelloader.service.ModelLoaderInterface#loadModel(java.lang.String) - */ - @Override - public Response loadModel(String modelid) { - Response response = Response.ok("{\"model_loaded\":\"" + modelid + "\"}").build(); - - return response; - } - - /** (non-Javadoc) - * @see org.openecomp.modelloader.service.ModelLoaderInterface#saveModel(java.lang.String, java.lang.String) - */ - @Override - public Response saveModel(String modelid, String modelname) { - Response response = Response.ok("{\"model_saved\":\"" + modelid + "-" + modelname + "\"}") - .build(); - - return response; - } - - @Override - public Response ingestModel(String modelid, HttpServletRequest req, String payload) - throws IOException { - Response response; - - if (config.getIngestSimulatorEnabled()) { - logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Received test artifact"); - - ModelArtifactHandler handler = new ModelArtifactHandler(config); - handler.loadModelTest(payload.getBytes()); - - response = Response.ok().build(); - } else { - logger.debug("Simulation interface disabled"); - response = Response.serverError().build(); - } - - return response; - } -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.service; + +import org.openecomp.sdc.api.IDistributionClient; +import org.openecomp.sdc.api.results.IDistributionClientResult; +import org.openecomp.sdc.impl.DistributionClientFactory; +import org.openecomp.sdc.utils.DistributionActionResultEnum; + +import org.openecomp.cl.api.Logger; +import org.openecomp.cl.eelf.LoggerFactory; +import org.openecomp.modelloader.config.ModelLoaderConfig; +import org.openecomp.modelloader.entity.model.ModelArtifactHandler; +import org.openecomp.modelloader.notification.EventCallback; + +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Properties; + +import javax.annotation.PreDestroy; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Response; + +/** + * Service class in charge of managing the negotiating model loading + * capabilities between AAI and an ASDC. + */ +public class ModelLoaderService implements ModelLoaderInterface { + + protected static final String FILESEP = (System.getProperty("file.separator") == null) ? "/" + : System.getProperty("file.separator"); + + protected static final String CONFIG_DIR = System.getProperty("CONFIG_HOME") + FILESEP; + protected static final String CONFIG_AUTH_LOCATION = CONFIG_DIR + "auth" + FILESEP; + protected static final String CONFIG_FILE = CONFIG_DIR + "model-loader.properties"; + + private IDistributionClient client; + private ModelLoaderConfig config; + + static Logger logger = LoggerFactory.getInstance().getLogger(ModelLoaderService.class.getName()); + + /** + * Responsible for loading configuration files and calling initialization. + */ + public ModelLoaderService() { + start(); + } + + protected void start() { + // Load model loader system configuration + logger.info(ModelLoaderMsgs.LOADING_CONFIGURATION); + Properties configProperties = new Properties(); + try { + configProperties.load(new FileInputStream(CONFIG_FILE)); + } catch (IOException e) { + String errorMsg = "Failed to load configuration: " + e.getMessage(); + logger.error(ModelLoaderMsgs.ASDC_CONNECTION_ERROR, errorMsg); + shutdown(); + } + + config = new ModelLoaderConfig(configProperties, CONFIG_AUTH_LOCATION); + init(); + } + + @Override + public void finalize() { + preShutdownOperations(); + } + + /** + * Responsible for stopping the connection to the distribution client before + * the resource is destroyed. + */ + protected void preShutdownOperations() { + logger.info(ModelLoaderMsgs.STOPPING_CLIENT); + if (client != null) { + client.stop(); + } + } + + /** + * Responsible for loading configuration files, initializing model + * distribution clients, and starting them. + */ + protected void init() { + // Initialize distribution client + logger.debug(ModelLoaderMsgs.INITIALIZING, "Initializing distribution client..."); + client = DistributionClientFactory.createDistributionClient(); + IDistributionClientResult initResult = client.init(config, new EventCallback(client, config)); + if (initResult.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { + String errorMsg = "Failed to initialize distribution client: " + + initResult.getDistributionMessageResult(); + logger.error(ModelLoaderMsgs.ASDC_CONNECTION_ERROR, errorMsg); + shutdown(); + } + + // Start distribution client + logger.debug(ModelLoaderMsgs.INITIALIZING, "Starting distribution client..."); + IDistributionClientResult startResult = client.start(); + if (startResult.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { + String errorMsg = "Failed to start distribution client: " + + startResult.getDistributionMessageResult(); + logger.error(ModelLoaderMsgs.ASDC_CONNECTION_ERROR, errorMsg); + shutdown(); + } + + logger.debug(ModelLoaderMsgs.INITIALIZING, + "Succcessfully loaded service: " + this.getClass().getSimpleName()); + } + + /** + * Shut down the process. + */ + private void shutdown() { + preShutdownOperations(); + + // TODO: Find a better way to shut down the model loader. + try { + // Give logs time to write to file + Thread.sleep(2000); + } catch (InterruptedException e) { + // Nothing we can do at this point + } + + Runtime.getRuntime().halt(1); + } + + /** (non-Javadoc) + * @see org.openecomp.modelloader.service.ModelLoaderInterface#loadModel(java.lang.String) + */ + @Override + public Response loadModel(String modelid) { + Response response = Response.ok("{\"model_loaded\":\"" + modelid + "\"}").build(); + + return response; + } + + /** (non-Javadoc) + * @see org.openecomp.modelloader.service.ModelLoaderInterface#saveModel(java.lang.String, java.lang.String) + */ + @Override + public Response saveModel(String modelid, String modelname) { + Response response = Response.ok("{\"model_saved\":\"" + modelid + "-" + modelname + "\"}") + .build(); + + return response; + } + + @Override + public Response ingestModel(String modelid, HttpServletRequest req, String payload) + throws IOException { + Response response; + + if (config.getIngestSimulatorEnabled()) { + logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Received test artifact"); + + ModelArtifactHandler handler = new ModelArtifactHandler(config); + handler.loadModelTest(payload.getBytes()); + + response = Response.ok().build(); + } else { + logger.debug("Simulation interface disabled"); + response = Response.serverError().build(); + } + + return response; + } +} diff --git a/src/main/java/org/openecomp/modelloader/util/JsonXmlConverter.java b/src/main/java/org/openecomp/modelloader/util/JsonXmlConverter.java index ca63b23..621f704 100644 --- a/src/main/java/org/openecomp/modelloader/util/JsonXmlConverter.java +++ b/src/main/java/org/openecomp/modelloader/util/JsonXmlConverter.java @@ -1,79 +1,81 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.util; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.XML; - -public class JsonXmlConverter { - - /** - * Determines whether or not the supplied text string represents a valid - * JSON structure or not. - * - * @param text - The text to be evaluated. - * - * @return - true if the string represents a valid JSON object, - * false, otherwise. - */ - public static boolean isValidJson(String text) { - try { - new JSONObject(text); - } catch (JSONException ex) { - try { - new JSONArray(text); - } catch (JSONException ex1) { - return false; - } - } - - return true; - } - - /** - * Takes a text string representing a valid JSON structure and converts it to - * an equivalent XML string. - * - * @param jsonText - The JSON string to convert to XML. - * - * @return - An XML string representation of the supplied JSON string. - */ - public static String convertJsonToXml(String jsonText) { - JSONObject jsonObj = new JSONObject(jsonText); - String xmlText = XML.toString(jsonObj); - return xmlText; - } - - /** - * Takes a text string representing a valid XML structure and converts it to - * an equivalent JSON string. - * - * @param xmlText - The XML string to convert to JSON. - * - * @return - A JSON string representation of the supplied XML string. - */ - public static String convertXmlToJson(String xmlText) { - JSONObject jsonObj = XML.toJSONObject(xmlText); - return jsonObj.toString(); - } -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.util; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.XML; + +public class JsonXmlConverter { + + /** + * Determines whether or not the supplied text string represents a valid + * JSON structure or not. + * + * @param text - The text to be evaluated. + * + * @return - true if the string represents a valid JSON object, + * false, otherwise. + */ + public static boolean isValidJson(String text) { + try { + new JSONObject(text); + } catch (JSONException ex) { + try { + new JSONArray(text); + } catch (JSONException ex1) { + return false; + } + } + + return true; + } + + /** + * Takes a text string representing a valid JSON structure and converts it to + * an equivalent XML string. + * + * @param jsonText - The JSON string to convert to XML. + * + * @return - An XML string representation of the supplied JSON string. + */ + public static String convertJsonToXml(String jsonText) { + JSONObject jsonObj = new JSONObject(jsonText); + String xmlText = XML.toString(jsonObj); + return xmlText; + } + + /** + * Takes a text string representing a valid XML structure and converts it to + * an equivalent JSON string. + * + * @param xmlText - The XML string to convert to JSON. + * + * @return - A JSON string representation of the supplied XML string. + */ + public static String convertXmlToJson(String xmlText) { + JSONObject jsonObj = XML.toJSONObject(xmlText); + return jsonObj.toString(); + } +} diff --git a/src/main/resources/aai-os-cert.p12 b/src/main/resources/aai-os-cert.p12 deleted file mode 100644 index ee57120fa0d5e5089c351930e668b87bde52e7e6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4357 zcmY+GWl$81w}%CmZdkg(C0E#`yX!?3kPbmgq(Mqj$wj1F=|(!2TsoHS6cD5v$wfi9 zzBBjU|Ggj1oSEl0=X`yBkWg|AObjeYC>aU|pBJtUM-yYc}@Tc-6n*90=X8$wx6RfnjED!$OUCM_G~*B8_-8GV{s ziZYnh-o^U3PKG!OGY?g9=RQL%$nnff&PK7}*S@JIzHGo$pxZIa(?O}NpfXuPs&*=* zvu>YHw3mpeHo3nhSYjRSo_p1QRE^EjQ4P9&}u=2oS>}^u+w;pvnmd;bGO_s`h zuohz_9*s$;l*0uXe!bN-!E?FpY-wdN^dHkAVoMwkpInKq-^nlVKWrIQ#@9isexbK0 zSP+Qd&PjcqKS~3fz+2Xj%Q6LaMg|1cd>PJJ0K2TAC+$X@M7@0w3%@u}S@)3ovS;Ll z${i{3Ezk2AI@RYSRrij+TDFrTcg@zNew!#RWa1sBLaW#jm7TPUi7xGwAHLFhO@KL_cKJ_$foWyun6h{`m3?gJU3Lcq&SbMsBb#9#b zHvJSMYu}A`XLn20&(W>#^cs{fl}Fj12v>?ougHZDwkgPsFz1*F=zvS#FK9~h!Ms)g`>_pQ z(~Ms|RY5;ZVW9We#1&B5_BHEF`I!UQEHxd(*_FNDi(l;~8QOAPM$-ce{gbf?j zt}}Oe5YnI24y!k4=v<8!9~Hq*%LxH?crdpdh9m}tWCb2-!3W~2o3aw2FLTldQ9WgW z9a0}F-Wz}2*Y2Qz#B@<(4s%tc$m6O~W%P&w$*C79mzXw0*dt{b`!#J|qyDij86-6) zfDlQJq9k~@jz1#wEjC%lsN#f4zvYRjGo0ep2L>3*QX&qWE@*olY#S0_RgraXzL%4} zbN3f@h-n1-C%n4o1|j+#cuOAc7G!(2JOlJHKl(~KC!Tc^~GV)bJhPQrq&lB(h9?*fKuWrxh!JOvT7gc2&&*2SVa`o_1lW~10& zJizmln{QCG7$VOK+6rH%i568UmQfloVY~WrNy1az+qI9YxHI)HbntT6+?mIwXsStB z3Civ)5%Ng@t+KT$C>n)run%mYBJ&#k4mND(ajKQ2n&D?+grwx2$!!abd`Fc7a%+Y5 zVONJ{F}ytUa)(z)?iNR1bGHXO3o5_yZ5$!9Rb3eKsRN7$;0OQlx;&aJ!60~G*v}et zEAV4jHAN#ew2&h-k(YX&UpM}zGUckh=T**_22KEL-qU26HSlgpAl!|~TXO!= z6H71C%X9vp<-BPTYLSMulsqe+k~9iUy=d*-%S*rzELT3OpZh0>#!*XrVs`g#G)(pt z|F1#7r+(gBRjxE?k!SuMTDK8<)G4!7ruTP3K51@yfZ4@J*qd9 z9GPejpmng)M&N>>vwo3#5a~Mi-ZSf`0p1%01bg-Oi1&PC-h4 zI|o~~r^?voQa~LuirPb5TO_4c7&ML$V$0(TILT-SUXIRJV{CmxU47qG+i<^0mPN;R z$HF(`k<v~_$Rb?flRvtN53hzB1US7lr5 zkLJscq9j>q$*>f}(=e--KbH@AfU>yMrgr03965k`<$Os?Q<-jYXD%wES)A{kB{L6+E6%UFbq4+)jM`(GW`1OEL{OZ5B{O^?D5dM$e z2rw}JhOU31;68!jyC` zJJ36mFFRL1Z@J2~*UL?|Ctw&ElVv-hOh<&M`-o} zN=>ykkSVstDFrrx9=uoe%I6wcWN;b>x}_8omAQWu=vJ7lrxUbzU+iMXNwRBXsVppf zb9gefemo003b?c1qfH2yKe>tOY5CCIKItVNCUN4v3E0G)0?G)ZZyNd0zJT1c-86Y0 zM&k_mh~(Vkx~B02bM=1P{QThXwub`c-?=`XLj0LmdVB1w(n0+ziAhcA6G>j`+~UOZ zKI^9;RpnuMWmjc6L2l@*ZzFMum;ABDW>PZ-mxV%E46Ps!-^r_|jbc}4#xZ433?5uTFPzR@JesCbjM%!I!MGa`TU8 zs=!}M1FWympFuNn6XUGjM!pV1D&qdxN*oukQs50(k|2mB!_hM$!ZzPI5s^AdJELEo z>>mFRXQ3{0E6WD%$zG=csxmoKs7qvcv^FQQD4rXP0vle^+xd)h9?-$ViDvAMi%606 z-So&At?Iq}FRYGd3Vd}M9CY44@S*a0l0-lYYq~4pty?m>1K)Dp>Pw|L^BYRXc(L(+ z6vc0+JEw->d|0N@IH97+bLg=&PC8O7iR;|0we-XFf{Z>Jbyi~g-;>Gv{9i^tMlgZ~ zw8N@Xjtc7eOUm=|8b44<4mb`_{zu4rF;4n9wp5$1@V3cr%{oQ4*Eq%N;u+IELf2;bK( z6IOO6Y79hc%aUE=_w{EwenJj0GWRL;+=ROw&J{z=?8Np(#(FvyB)W(hK3z=!tC1I> zRSMqwWhB0@jf5c~!bZc0z`7c`?){yUPNx#YD;l6mFbTG`Z%lKEuFWBRliL=pFF2(a z3p-U)`{W8ih|l;G6#PVf8bwrUL@@bAm^Gj5Q?{_Q(2+F%N>|RQM*lea)dW7Vzrfv9X;09sr(?k zcqBSC7+~k?IJh6-+gr+V4>0G$LBSn%mpB@JPGu>7+{4xe-Bv~IA`%E)ZM6C3O$?chb&0?IzI%^7Gj+1KbYHl4V zPd}=`I=Ez_VtV=(SI{rxSOCzvx*vv3Q=+*hdGlU-W3}MM-1EA)caf}Cic9>ua#MOh z@Oo|)U%Fs~{VoYQK4}6uPljxhqcSpFK>7c9?6@fqI?`f&* zA467o<~lO^#LxjxZa|5jL)^n$4#hv1^Iye5WjzMsJDK{~dKV+wwr{soN03}MZwoD( zJj%p?iNymqxlqt+m{9VEr&VT!2I{pJBApl1{3CC<)=uZkJI3v<_=R}f>8Wrrkq9qP zub5ZfK=0ji!BD)9-C@BHzG%*Yaf;v`DkVyH)7uPYy3Ju59I#Oeeab~$1VuO6ILW^8 z`&3q_!%_d&XkF(xmB5~&cQ=);3n*-inFX;FZ~QYPh0pX(k-NX&ow}r+#AyC5`S0gLgGh6~v zJCJ~Zj&pc(@HU1yS=ZmKFUA(m z?2v-5!RZw?^{A{_iOpu%Xry-)qJvOBkh$rzoqb^Osz_gh+wIKi?8*Dc`?WwriOdJJfZQp(Z|PX`lV$(0CaO{K{Rviq>H5%=~8D;ubGJCfLy-V zWjl@%Ge+gMiVE8BA=z5FHl>?3aXd(VnHb|tS(o^QBsje{!=FXuLpv%<;hLq(0%oKL!rNz^E;^m^+UbCB~)FV23k zWz}HN_TwlFyw}$9LnnxZ25vhQzLZCPqln#wF5jGul}VbuKnQz%6MWTzRw0xzD(9<9 zJN1uZ-=(SuOwSbQINb2pu}mnmACAsDqdEr`k-c`eE;Rp6p5Z<1yRh_4QD)jhs2O zJbA(CWeBAHym(FDe_H^S_Ll}f4UX#nhQAuwLL_E7Skp46DH(JywX~2fjZ*Wvvb4^r0|Lnbi2KQZPQt| zrh;fRwBdtHoyTDx7dzGYQ;Hz>Qn2bl6<<=M<;v02orfS64W{Yz{+}pC_!|fm!Un;|!R8~u s!lcK30s!`$(Z1lZj{F4bjFD-@{t`5Fq;~?qQ!4r1OqX>o@o!7}FACd2%K!iX diff --git a/src/main/resources/org/openecomp/modelloader/filemonitor/FileMonitorMsgs.properties b/src/main/resources/org/openecomp/modelloader/filemonitor/FileMonitorMsgs.properties deleted file mode 100644 index 9abd55c..0000000 --- a/src/main/resources/org/openecomp/modelloader/filemonitor/FileMonitorMsgs.properties +++ /dev/null @@ -1,81 +0,0 @@ -### -# ============LICENSE_START======================================================= -# MODEL LOADER SERVICE -# ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -### - -#Resource key=Error Code|Message text|Resolution text |Description text -####### -#Newlines can be utilized to add some clarity ensuring continuing line -#has atleast one leading space -#ResourceKey=\ -# ERR0000E\ -# Sample error msg txt\ -# Sample resolution msg\ -# Sample description txt -# -###### -#Error code classification category -#100 Permission errors -#200 Availability errors/Timeouts -#300 Data errors -#400 Schema Interface type/validation errors -#500 Business process errors -#900 Unknown errors -# -######################################################################## - -#AVAILABILITY ERRORS - -LOADING_FROM_FILE=\ - FILEMON2001I|\ - Loading service properties from file {0}|\ - None. Attempting to load file|\ - Attempting to load service properties from the given service file - -FILE_SUCCESSFULLY_LOADED=\ - FILEMON2002I|\ - File {0} is loaded into the map and the corresponding system properties have been refreshed|\ - None. Successfully loaded file|\ - The given service file and its properties were successfully loaded - -FILE_CANNOT_BE_LOADED=\ - FILEMON2003E|\ - File {0} cannot be loaded into the map|\ - Please check the file permissions and format of the file|\ - Unable to load the given service file due to an error - -CANNOT_READ_FILE_STREAM=\ - FILEMON2004E|\ - Error reading the file stream for file {0}|\ - Please ensure that the file exists and the permissions are set correctly|\ - Unable to read the file stream for the given file - -#UNKNOWN ERRORS - -FILE_LISTENER_ATTACH_FAILED=\ - FILEMON9002W|\ - Unable to attach file change listener to file {0} due to an internal error|\ - Failed to attach file change listener to the given file. Please check the reported exception for details|\ - The file will not be actively monitored for changes - - -PROP_MAP_CREATION_FAILED=\ - FILEMON9001E|\ - Internal Error occurred while creating property map for service files|\ - Error occurred due to an internal issue. Please check the reported exception for details |\ - Failed to create a property map for the service files diff --git a/src/main/resources/org/openecomp/modelloader/service/ModelLoaderMsgs.properties b/src/main/resources/org/openecomp/modelloader/service/ModelLoaderMsgs.properties index 53c96dc..8e2d043 100644 --- a/src/main/resources/org/openecomp/modelloader/service/ModelLoaderMsgs.properties +++ b/src/main/resources/org/openecomp/modelloader/service/ModelLoaderMsgs.properties @@ -1,112 +1,118 @@ -### +### # ============LICENSE_START======================================================= # MODEL LOADER SERVICE # ================================================================================ # Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. # ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and # limitations under the License. -# ============LICENSE_END========================================================= -### - -#Resource key=Error Code|Message text|Resolution text |Description text -####### -#Newlines can be utilized to add some clarity ensuring continuing line -#has at least one leading space -#ResourceKey=\ -# ERR0000E\ -# Sample error msg txt\ -# Sample resolution msg\ -# Sample description txt -# -###### -#Error code classification category -#000 Info/Debug -#100 Permission errors -#200 Availability errors/Timeouts -#300 Data errors -#400 Schema Interface type/validation errors -#500 Business process errors -#900 Unknown errors -# -######################################################################## - -# INFO Level Logs -LOADING_CONFIGURATION=\ - MDLSVC0001I|\ - Loading configuration |\ - None. Attempting to load configuration|\ - Attempting to load Model Loader Service configuration - -STOPPING_CLIENT=\ - MDLSVC0002I|\ - Stopping distribution client|\ - None. Stopping service|\ - Stopping the Model Service distribution client - -DISTRIBUTION_EVENT=\ - MDLSVC0003I|\ - Distribution event: {0}|\ - None. Processing distribution.|\ - A distribution event was received from the ASDC - -AAI_REST_REQUEST_SUCCESS=\ - MDLSVC0004I|\ - Sent {0} request to {1}. Response: {2}|\ - None. Successfully sent REST request to AAI.|\ - The given request was sent to the specified endpoint. - -AAI_REST_REQUEST_UNSUCCESSFUL=\ - MDLSVC0005I|\ - Sent {0} request to {1}. Response code: {2}, Response message: {3}|\ - REST request to AAI unsuccessful. Check response code, and message. |\ - The given request was unsuccessful. - -DOWNLOAD_COMPLETE=\ - MDLSVC0006I|\ - Download of artifact {0} from ASDC complete. Result: {1}|\ - None.|\ - An artifact was downloaded from the ASDC - -EVENT_PUBLISHED=\ - MDLSVC0007I|\ - Published {0} event for artifact {1}. Result: {2}|\ - None.|\ - An event was published to the event bus - -# ERROR Level Logs -ASDC_CONNECTION_ERROR=\ - MDLSVC2001E|\ - Unable to register with ASDC: {0}|\ - Check configuration. Check network connection to ASDC|\ - During initialization, was not able to register with the configured ASDC instance - -DISTRIBUTION_EVENT_ERROR=\ - MDLSVC2002E|\ - Distribution event error: {0}|\ - Check configuration. Check network connection to ASDC and UEB|\ - A failure occurred processing a distribution event - -AAI_REST_REQUEST_ERROR=\ - MDLSVC2003E|\ - Failed to send {0} request to {1}: {2}|\ - Check configuration. Check network connection to AAI.|\ - A failure occurred attempting to send a request to the AAI - -# DEBUG Level Logs -INITIALIZING=\ - MDLSVC0001D|\ - init(): {0}|\ - None. Initializing service|\ - Debug information during model loader initialization - - +# ============LICENSE_END========================================================= +### + +#Resource key=Error Code|Message text|Resolution text |Description text +####### +#Newlines can be utilized to add some clarity ensuring continuing line +#has at least one leading space +#ResourceKey=\ +# ERR0000E\ +# Sample error msg txt\ +# Sample resolution msg\ +# Sample description txt +# +###### +#Error code classification category +#000 Info/Debug +#100 Permission errors +#200 Availability errors/Timeouts +#300 Data errors +#400 Schema Interface type/validation errors +#500 Business process errors +#900 Unknown errors +# +######################################################################## + +# INFO Level Logs +LOADING_CONFIGURATION=\ + MDLSVC0001I|\ + Loading configuration |\ + None. Attempting to load configuration|\ + Attempting to load Model Loader Service configuration + +STOPPING_CLIENT=\ + MDLSVC0002I|\ + Stopping distribution client|\ + None. Stopping service|\ + Stopping the Model Service distribution client + +DISTRIBUTION_EVENT=\ + MDLSVC0003I|\ + Distribution event: {0}|\ + None. Processing distribution.|\ + A distribution event was received from the ASDC + +AAI_REST_REQUEST_SUCCESS=\ + MDLSVC0004I|\ + Sent {0} request to {1}. Response: {2}|\ + None. Successfully sent REST request to AAI.|\ + The given request was sent to the specified endpoint. + +AAI_REST_REQUEST_UNSUCCESSFUL=\ + MDLSVC0005I|\ + Sent {0} request to {1}. Response code: {2}, Response message: {3}|\ + REST request to AAI unsuccessful. Check response code, and message. |\ + The given request was unsuccessful. + +DOWNLOAD_COMPLETE=\ + MDLSVC0006I|\ + Download of artifact {0} from ASDC complete. Result: {1}|\ + None.|\ + An artifact was downloaded from the ASDC + +EVENT_PUBLISHED=\ + MDLSVC0007I|\ + Published {0} event for artifact {1}. Result: {2}|\ + None.|\ + An event was published to the event bus + +# ERROR Level Logs +ASDC_CONNECTION_ERROR=\ + MDLSVC2001E|\ + Unable to register with ASDC: {0}|\ + Check configuration. Check network connection to ASDC|\ + During initialization, was not able to register with the configured ASDC instance + +DISTRIBUTION_EVENT_ERROR=\ + MDLSVC2002E|\ + Distribution event error: {0}|\ + Check configuration. Check network connection to ASDC and UEB|\ + A failure occurred processing a distribution event + +AAI_REST_REQUEST_ERROR=\ + MDLSVC2003E|\ + Failed to send {0} request to {1}: {2}|\ + Check configuration. Check network connection to AAI.|\ + A failure occurred attempting to send a request to the AAI + +ARTIFACT_PARSE_ERROR=\ + MDLSVC2004E|\ + Failed to parse artifact: {0}|\ + Check artifact. |\ + A failure occurred attempting to parse artifact from SDC + +# DEBUG Level Logs +INITIALIZING=\ + MDLSVC0001D|\ + init(): {0}|\ + None. Initializing service|\ + Debug information during model loader initialization + + diff --git a/src/main/resources/schema/aai_schema_v8.xsd b/src/main/resources/schema/aai_schema_v8.xsd index 66bc3db..14f2610 100644 --- a/src/main/resources/schema/aai_schema_v8.xsd +++ b/src/main/resources/schema/aai_schema_v8.xsd @@ -1,2462 +1,2462 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + ============LICENSE_END========================================================= + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/schema/vnfcatalog.xsd b/src/main/resources/schema/vnfcatalog.xsd index 9789124..1b18ef1 100644 --- a/src/main/resources/schema/vnfcatalog.xsd +++ b/src/main/resources/schema/vnfcatalog.xsd @@ -1,127 +1,127 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + ============LICENSE_END========================================================= + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/runtime/context/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.context b/src/main/runtime/context/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.context new file mode 100644 index 0000000..8514196 --- /dev/null +++ b/src/main/runtime/context/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.context @@ -0,0 +1 @@ +{"context":{"contextClass":"ajsc.Context","contextId":"__module_ajsc_namespace_name__:__module_ajsc_namespace_version__","contextName":"__module_ajsc_namespace_name__","contextVersion":"__module_ajsc_namespace_version__","description":"__module_ajsc_namespace_name__ Context"}} \ No newline at end of file diff --git a/src/main/runtime/context/default#0.context b/src/main/runtime/context/default#0.context new file mode 100644 index 0000000..d1b5ab4 --- /dev/null +++ b/src/main/runtime/context/default#0.context @@ -0,0 +1 @@ +{"context":{"contextClass":"ajsc.Context","contextId":"default:0","contextName":"default","contextVersion":"0","description":"Default Context"}} \ No newline at end of file diff --git a/src/main/runtime/deploymentPackage/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.json b/src/main/runtime/deploymentPackage/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.json new file mode 100644 index 0000000..d0954cf --- /dev/null +++ b/src/main/runtime/deploymentPackage/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.json @@ -0,0 +1 @@ +{"deploymentPackage":{"Class":"ajsc.DeploymentPackage","Id":"__module.ajsc.namespace.name__:__module_ajsc_namespace_version__","namespace":"__module_ajsc_namespace_name__","namespaceVersion":"__module_ajsc_namespace_version__","description":"__module_ajsc_namespace_name__ __module_ajsc_namespace_version__ - default description","userId":"ajsc"}} \ No newline at end of file diff --git a/src/main/runtime/shiroRole/ajscadmin.json b/src/main/runtime/shiroRole/ajscadmin.json new file mode 100644 index 0000000..f5e981e --- /dev/null +++ b/src/main/runtime/shiroRole/ajscadmin.json @@ -0,0 +1 @@ +{"shiroRoleClass":"ajsc.auth.ShiroRole","shiroRoleId":"ajscadmin","name":"ajscadmin","permissions":"[ajscadmin:*, ajsc:*]"} \ No newline at end of file diff --git a/src/main/runtime/shiroRole/contextadmin#__module.ajsc.namespace.name__.json b/src/main/runtime/shiroRole/contextadmin#__module.ajsc.namespace.name__.json new file mode 100644 index 0000000..2dae9f5 --- /dev/null +++ b/src/main/runtime/shiroRole/contextadmin#__module.ajsc.namespace.name__.json @@ -0,0 +1 @@ +{"shiroRoleClass":"ajsc.auth.ShiroRole","shiroRoleId":"contextadmin:__module_ajsc_namespace_name__","name":"contextadmin:__module_ajsc_namespace_name__","permissions":"[]"} \ No newline at end of file diff --git a/src/main/runtime/shiroRole/contextadmin#default.json b/src/main/runtime/shiroRole/contextadmin#default.json new file mode 100644 index 0000000..5de814e --- /dev/null +++ b/src/main/runtime/shiroRole/contextadmin#default.json @@ -0,0 +1 @@ +{"shiroRoleClass":"ajsc.auth.ShiroRole","shiroRoleId":"contextadmin:default","name":"contextadmin:default","permissions":"[]"} \ No newline at end of file diff --git a/src/main/runtime/shiroUser/ajsc.json b/src/main/runtime/shiroUser/ajsc.json new file mode 100644 index 0000000..f4c7855 --- /dev/null +++ b/src/main/runtime/shiroUser/ajsc.json @@ -0,0 +1 @@ +{"shiroUserClass":"ajsc.auth.ShiroUser","shiroUserId":"ajsc","passwordHash":"9471697417008c880720ba54c6038791ad7e98f3b88136fe34f4d31a462dd27a","permissions":"[*:*]","username":"ajsc"} \ No newline at end of file diff --git a/src/main/runtime/shiroUserRole/ajsc#ajscadmin.json b/src/main/runtime/shiroUserRole/ajsc#ajscadmin.json new file mode 100644 index 0000000..cb8d483 --- /dev/null +++ b/src/main/runtime/shiroUserRole/ajsc#ajscadmin.json @@ -0,0 +1 @@ +{"shiroUserRoleClass":"ajsc.auth.ShiroUserRole","shiroUserRoleId":"ajsc:ajscadmin","roleId":"ajscadmin","userId":"ajsc"} \ No newline at end of file diff --git a/src/main/runtime/shiroUserRole/ajsc#contextadmin#__module.ajsc.namespace.name__.json b/src/main/runtime/shiroUserRole/ajsc#contextadmin#__module.ajsc.namespace.name__.json new file mode 100644 index 0000000..95d2361 --- /dev/null +++ b/src/main/runtime/shiroUserRole/ajsc#contextadmin#__module.ajsc.namespace.name__.json @@ -0,0 +1 @@ +{"shiroUserRoleClass":"ajsc.auth.ShiroUserRole","shiroUserRoleId":"ajsc:contextadmin:__module_ajsc_namespace_name__","roleId":"contextadmin:__module_ajsc_namespace_name__","userId":"ajsc"} \ No newline at end of file diff --git a/src/main/runtime/shiroUserRole/ajsc#contextadmin#default.json b/src/main/runtime/shiroUserRole/ajsc#contextadmin#default.json new file mode 100644 index 0000000..2bd5063 --- /dev/null +++ b/src/main/runtime/shiroUserRole/ajsc#contextadmin#default.json @@ -0,0 +1 @@ +{"shiroUserRoleClass":"ajsc.auth.ShiroUserRole","shiroUserRoleId":"ajsc:contextadmin:default","roleId":"contextadmin:default","userId":"ajsc"} \ No newline at end of file diff --git a/src/test/java/org/openecomp/modelloader/config/ModelLoaderConfigTest.java b/src/test/java/org/openecomp/modelloader/config/ModelLoaderConfigTest.java index 4018f14..0d068d5 100644 --- a/src/test/java/org/openecomp/modelloader/config/ModelLoaderConfigTest.java +++ b/src/test/java/org/openecomp/modelloader/config/ModelLoaderConfigTest.java @@ -1,122 +1,125 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.config; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; - -import java.io.FileInputStream; -import java.io.IOException; -import java.util.List; -import java.util.Properties; - -import org.eclipse.jetty.util.security.Password; -import org.junit.Test; -import org.openecomp.modelloader.restclient.AaiRestClient; - -import org.openecomp.sdc.utils.ArtifactTypeEnum; - -public class ModelLoaderConfigTest { - - @Test - public void testYangModelArtifactType() { - Properties props = new Properties(); - props.setProperty("ml.distribution.ARTIFACT_TYPES", - "MODEL_INVENTORY_PROFILE,MODEL_QUERY_SPEC,VNF_CATALOG"); - ModelLoaderConfig config = new ModelLoaderConfig(props); - - List types = config.getRelevantArtifactTypes(); - - System.out.println("ArtifactType: " + types.get(0)); - assertEquals(0, - types.get(0).compareToIgnoreCase(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.toString())); - - System.out.println("ArtifactType: " + types.get(1)); - assertEquals(0, types.get(1).compareToIgnoreCase(ArtifactTypeEnum.MODEL_QUERY_SPEC.toString())); - - System.out.println("ArtifactType: " + types.get(2)); - assertEquals(0, types.get(2).compareToIgnoreCase(ArtifactTypeEnum.VNF_CATALOG.toString())); - - assertEquals(3, types.size()); - } - - @Test - public void testDecryptPassword() { - Properties props = new Properties(); - String testPass = "youshallnotpass"; - String encryptedTestPass = Password.obfuscate(testPass); - - System.out.println("Encrypt " + testPass + " ==> " + encryptedTestPass); - - props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_PASSWORD, encryptedTestPass); - ModelLoaderConfig config = new ModelLoaderConfig(props); - - assertEquals(testPass, config.getPassword()); - } - - @Test - public void testDecryptKeystorePassword() { - Properties props = new Properties(); - String testPass = "youshallnotpass"; - String encryptedTestPass = Password.obfuscate(testPass); - - System.out.println("Encrypt " + testPass + " ==> " + encryptedTestPass); - - props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD, encryptedTestPass); - ModelLoaderConfig config = new ModelLoaderConfig(props); - - assertEquals(testPass, config.getKeyStorePassword()); - } - - @Test - public void testDecryptAAIPassword() { - - Properties props = new Properties(); - String testPassword = "myvoiceismypassword"; - String encryptedTestPassword = Password.obfuscate(testPassword); - - props.put(ModelLoaderConfig.PROP_AAI_AUTHENTICATION_PASSWORD, encryptedTestPassword); - ModelLoaderConfig config = new ModelLoaderConfig(props); - - assertEquals(testPassword, config.getAaiAuthenticationPassword()); - } - - @Test - public void testNoAAIAuth() throws IOException { - - Properties props = new Properties(); - props.load( - new FileInputStream("src/test/resources/model-loader-empty-auth-password.properties")); - - ModelLoaderConfig config = new ModelLoaderConfig(props); - AaiRestClient aaiClient = new AaiRestClient(config); - - assertFalse("Empty AAI Password should result in no basic authentication", - aaiClient.useBasicAuth()); - - props.load(new FileInputStream("src/test/resources/model-loader-no-auth-password.properties")); - config = new ModelLoaderConfig(props); - aaiClient = new AaiRestClient(config); - - assertFalse("No AAI Password should result in no basic authentication", - aaiClient.useBasicAuth()); - } -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.config; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.io.FileInputStream; +import java.io.IOException; +import java.util.List; +import java.util.Properties; + +import org.eclipse.jetty.util.security.Password; +import org.junit.Test; +import org.openecomp.modelloader.restclient.AaiRestClient; + +import org.openecomp.sdc.utils.ArtifactTypeEnum; + +public class ModelLoaderConfigTest { + + @Test + public void testYangModelArtifactType() { + Properties props = new Properties(); + props.setProperty("ml.distribution.ARTIFACT_TYPES", + "MODEL_INVENTORY_PROFILE,MODEL_QUERY_SPEC,VNF_CATALOG"); + ModelLoaderConfig config = new ModelLoaderConfig(props, null); + + List types = config.getRelevantArtifactTypes(); + + System.out.println("ArtifactType: " + types.get(0)); + assertEquals(0, + types.get(0).compareToIgnoreCase(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.toString())); + + System.out.println("ArtifactType: " + types.get(1)); + assertEquals(0, types.get(1).compareToIgnoreCase(ArtifactTypeEnum.MODEL_QUERY_SPEC.toString())); + + System.out.println("ArtifactType: " + types.get(2)); + assertEquals(0, types.get(2).compareToIgnoreCase(ArtifactTypeEnum.VNF_CATALOG.toString())); + + assertEquals(3, types.size()); + } + + @Test + public void testDecryptPassword() { + Properties props = new Properties(); + String testPass = "youshallnotpass"; + String encryptedTestPass = Password.obfuscate(testPass); + + System.out.println("Encrypt " + testPass + " ==> " + encryptedTestPass); + + props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_PASSWORD, encryptedTestPass); + ModelLoaderConfig config = new ModelLoaderConfig(props, null); + + assertEquals(testPass, config.getPassword()); + } + + @Test + public void testDecryptKeystorePassword() { + Properties props = new Properties(); + String testPass = "youshallnotpass"; + String encryptedTestPass = Password.obfuscate(testPass); + + System.out.println("Encrypt " + testPass + " ==> " + encryptedTestPass); + + props.put(ModelLoaderConfig.PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD, encryptedTestPass); + ModelLoaderConfig config = new ModelLoaderConfig(props, null); + + assertEquals(testPass, config.getKeyStorePassword()); + } + + @Test + public void testDecryptAAIPassword() { + + Properties props = new Properties(); + String testPassword = "myvoiceismypassword"; + String encryptedTestPassword = Password.obfuscate(testPassword); + + props.put(ModelLoaderConfig.PROP_AAI_AUTHENTICATION_PASSWORD, encryptedTestPassword); + ModelLoaderConfig config = new ModelLoaderConfig(props, null); + + assertEquals(testPassword, config.getAaiAuthenticationPassword()); + } + + @Test + public void testNoAAIAuth() throws IOException { + + Properties props = new Properties(); + props.load( + new FileInputStream("src/test/resources/model-loader-empty-auth-password.properties")); + + ModelLoaderConfig config = new ModelLoaderConfig(props, null); + AaiRestClient aaiClient = new AaiRestClient(config); + + assertFalse("Empty AAI Password should result in no basic authentication", + aaiClient.useBasicAuth()); + + props.load(new FileInputStream("src/test/resources/model-loader-no-auth-password.properties")); + config = new ModelLoaderConfig(props, null); + aaiClient = new AaiRestClient(config); + + assertFalse("No AAI Password should result in no basic authentication", + aaiClient.useBasicAuth()); + } + +} diff --git a/src/test/java/org/openecomp/modelloader/entity/catalog/VnfCatalogArtifactHandlerTest.java b/src/test/java/org/openecomp/modelloader/entity/catalog/VnfCatalogArtifactHandlerTest.java index 1b1d955..c81b51d 100644 --- a/src/test/java/org/openecomp/modelloader/entity/catalog/VnfCatalogArtifactHandlerTest.java +++ b/src/test/java/org/openecomp/modelloader/entity/catalog/VnfCatalogArtifactHandlerTest.java @@ -1,98 +1,100 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.entity.catalog; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -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.Properties; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import org.openecomp.modelloader.config.ModelLoaderConfig; -import org.openecomp.modelloader.entity.Artifact; -import org.openecomp.modelloader.restclient.AaiRestClient; -import org.openecomp.modelloader.restclient.AaiRestClient.MimeType; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import com.sun.jersey.api.client.ClientResponse; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({ VnfCatalogArtifactHandler.class, ClientResponse.class, AaiRestClient.class }) -public class VnfCatalogArtifactHandlerTest { - - protected static String CONFIG_FILE = "model-loader.properties"; - - @Test - public void testWithMocks() throws Exception { - - Properties configProperties = new Properties(); - try { - configProperties.load(this.getClass().getClassLoader().getResourceAsStream(CONFIG_FILE)); - } catch (IOException e) { - fail(); - } - ModelLoaderConfig config = new ModelLoaderConfig(configProperties); - - ClientResponse mockGetResp = PowerMockito.mock(ClientResponse.class); - PowerMockito.when(mockGetResp.getStatus()).thenReturn(200).thenReturn(200).thenReturn(404) - .thenReturn(404).thenReturn(200); // only second two will be PUT - ClientResponse mockPutResp = PowerMockito.mock(ClientResponse.class); - PowerMockito.when(mockPutResp.getStatus()).thenReturn(201); - - AaiRestClient mockRestClient = PowerMockito.mock(AaiRestClient.class); - PowerMockito.whenNew(AaiRestClient.class).withAnyArguments().thenReturn(mockRestClient); - PowerMockito.when(mockRestClient.getResource(Mockito.anyString(), Mockito.anyString(), - Mockito.any(MimeType.class))).thenReturn(mockGetResp); - PowerMockito.when(mockRestClient.putResource(Mockito.anyString(), Mockito.anyString(), - Mockito.anyString(), Mockito.any(MimeType.class))).thenReturn(mockPutResp); - - VnfCatalogArtifactHandler vnfCAH = new VnfCatalogArtifactHandler(config); - - String examplePath = "src/test/resources/vnfcatalogexample.xml"; - - byte[] encoded = Files.readAllBytes(Paths.get(examplePath)); - String payload = new String(encoded, "utf-8"); - - VnfCatalogArtifact artifact = new VnfCatalogArtifact(payload); - List artifacts = new ArrayList(); - artifacts.add(artifact); - - String distributionID = "test"; - - assertTrue(vnfCAH.pushArtifacts(artifacts, distributionID)); - // times(2) bc with above get returns should only get to this part twice - ArgumentCaptor argument = ArgumentCaptor.forClass(String.class); - Mockito.verify(mockRestClient, Mockito.times(2)).putResource(Mockito.anyString(), - argument.capture(), Mockito.anyString(), Mockito.any(MimeType.class)); - assertTrue(argument.getAllValues().get(0).contains("5.2.5")); - assertTrue(argument.getAllValues().get(1).contains("5.2.4")); - } -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.entity.catalog; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +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.Properties; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Mockito; +import org.openecomp.modelloader.config.ModelLoaderConfig; +import org.openecomp.modelloader.entity.Artifact; +import org.openecomp.modelloader.restclient.AaiRestClient; +import org.openecomp.modelloader.restclient.AaiRestClient.MimeType; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.sun.jersey.api.client.ClientResponse; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ VnfCatalogArtifactHandler.class, ClientResponse.class, AaiRestClient.class }) +public class VnfCatalogArtifactHandlerTest { + + protected static String CONFIG_FILE = "model-loader.properties"; + + @Test + public void testWithMocks() throws Exception { + + Properties configProperties = new Properties(); + try { + configProperties.load(this.getClass().getClassLoader().getResourceAsStream(CONFIG_FILE)); + } catch (IOException e) { + fail(); + } + ModelLoaderConfig config = new ModelLoaderConfig(configProperties, null); + + ClientResponse mockGetResp = PowerMockito.mock(ClientResponse.class); + PowerMockito.when(mockGetResp.getStatus()).thenReturn(200).thenReturn(200).thenReturn(404) + .thenReturn(404).thenReturn(200); // only second two will be PUT + ClientResponse mockPutResp = PowerMockito.mock(ClientResponse.class); + PowerMockito.when(mockPutResp.getStatus()).thenReturn(201); + + AaiRestClient mockRestClient = PowerMockito.mock(AaiRestClient.class); + PowerMockito.whenNew(AaiRestClient.class).withAnyArguments().thenReturn(mockRestClient); + PowerMockito.when(mockRestClient.getResource(Mockito.anyString(), Mockito.anyString(), + Mockito.any(MimeType.class))).thenReturn(mockGetResp); + PowerMockito.when(mockRestClient.putResource(Mockito.anyString(), Mockito.anyString(), + Mockito.anyString(), Mockito.any(MimeType.class))).thenReturn(mockPutResp); + + VnfCatalogArtifactHandler vnfCAH = new VnfCatalogArtifactHandler(config); + + String examplePath = "src/test/resources/vnfcatalogexample.xml"; + + byte[] encoded = Files.readAllBytes(Paths.get(examplePath)); + String payload = new String(encoded, "utf-8"); + + VnfCatalogArtifact artifact = new VnfCatalogArtifact(payload); + List artifacts = new ArrayList(); + artifacts.add(artifact); + + String distributionID = "test"; + + assertTrue(vnfCAH.pushArtifacts(artifacts, distributionID)); + // times(2) bc with above get returns should only get to this part twice + ArgumentCaptor argument = ArgumentCaptor.forClass(String.class); + Mockito.verify(mockRestClient, Mockito.times(2)).putResource(Mockito.anyString(), + argument.capture(), Mockito.anyString(), Mockito.any(MimeType.class)); + assertTrue(argument.getAllValues().get(0).contains("5.2.5")); + assertTrue(argument.getAllValues().get(1).contains("5.2.4")); + } +} diff --git a/src/test/java/org/openecomp/modelloader/entity/model/ModelArtifactParserTest.java b/src/test/java/org/openecomp/modelloader/entity/model/ModelArtifactParserTest.java index f7b7871..994c4db 100644 --- a/src/test/java/org/openecomp/modelloader/entity/model/ModelArtifactParserTest.java +++ b/src/test/java/org/openecomp/modelloader/entity/model/ModelArtifactParserTest.java @@ -1,151 +1,205 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.entity.model; - -import static org.junit.Assert.assertTrue; - -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.List; - -import org.junit.Test; -import org.openecomp.modelloader.entity.Artifact; - -public class ModelArtifactParserTest { - - @Test - public void testParseModelFileNoDeps() throws Exception { - final String MODEL_FILE = "src/test/resources/models/vnf-model.xml"; - - try { - byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE)); - - ModelArtifactParser parser = new ModelArtifactParser(); - List modelList = parser.parse(xmlBytes, "test-artifact"); - - assertTrue(modelList.size() == 1); - - ModelArtifact model = (ModelArtifact) modelList.get(0); - System.out.println(model.toString()); - - assertTrue(model.getNameVersionId().equalsIgnoreCase("model-vid")); - assertTrue(model.getType().toString().equalsIgnoreCase("MODEL")); - assertTrue(model.getDependentModelIds().size() == 0); - } catch (Exception e) { - e.printStackTrace(); - assertTrue(false); - } - } - - @Test - public void testParseModelFileDeps() throws Exception { - final String MODEL_FILE = "src/test/resources/models/wan-connector-model.xml"; - - try { - byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE)); - - ModelArtifactParser parser = new ModelArtifactParser(); - List modelList = parser.parse(xmlBytes, "test-artifact"); - - assertTrue(modelList.size() == 1); - - ModelArtifact model = (ModelArtifact) modelList.get(0); - System.out.println(model.toString()); - - assertTrue(model.getNameVersionId().equalsIgnoreCase("93d9d45d-7eec-4371-9083-675e4c353de3")); - assertTrue(model.getType().toString().equalsIgnoreCase("MODEL")); - assertTrue(model.getDependentModelIds().size() == 7); - assertTrue(model.getDependentModelIds().contains("d09dd9da-0148-46cd-a947-591afc844d24")); - assertTrue(model.getDependentModelIds().contains("ae16244f-4d29-4801-a559-e25f2db2a4c3")); - assertTrue(model.getDependentModelIds().contains("a6d9de88-4046-4b78-a59e-5691243d292a")); - } catch (Exception e) { - e.printStackTrace(); - assertTrue(false); - } - } - - @Test - public void testParseCompleteModel() throws Exception { - final String MODEL_FILE = "src/test/resources/models/complete-model.xml"; - - try { - byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE)); - - ModelArtifactParser parser = new ModelArtifactParser(); - List modelList = parser.parse(xmlBytes, "test-artifact"); - - for (Artifact art : modelList) { - ModelArtifact model = (ModelArtifact) art; - System.out.println(model.toString()); - } - - assertTrue(modelList.size() == 3); - - ModelArtifact modelVdc = (ModelArtifact) modelList.get(0); - assertTrue( - modelVdc.getNameVersionId().equalsIgnoreCase("997fc7-fca1-451f-b953-9a1e6197b4d6")); - assertTrue(modelVdc.getType().toString().equalsIgnoreCase("MODEL")); - assertTrue(modelVdc.getDependentModelIds().size() == 1); - assertTrue(modelVdc.getDependentModelIds().contains("93d9d45d-7eec-4371-9083-675e4c353de3")); - - ModelArtifact modelPserver = (ModelArtifact) modelList.get(2); - assertTrue( - modelPserver.getNameVersionId().equalsIgnoreCase("f2b24d95-c582-48d5-b2d6-c5b3a94ce812")); - assertTrue(modelPserver.getType().toString().equalsIgnoreCase("MODEL")); - assertTrue(modelPserver.getDependentModelIds().size() == 2); - assertTrue( - modelPserver.getDependentModelIds().contains("35be1acf-1298-48c6-a128-66850083b8bd")); - assertTrue( - modelPserver.getDependentModelIds().contains("759dbd4a-2473-46f3-a932-48d987c9b4a1")); - } catch (Exception e) { - e.printStackTrace(); - assertTrue(false); - } - } - - @Test - public void testParseNamedQuery() throws Exception { - final String MODEL_FILE = "src/test/resources/models/named-query-wan-connector.xml"; - - try { - byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE)); - - ModelArtifactParser parser = new ModelArtifactParser(); - List modelList = parser.parse(xmlBytes, "test-artifact"); - - assertTrue(modelList.size() == 1); - - ModelArtifact model = (ModelArtifact) modelList.get(0); - System.out.println(model.toString()); - - assertTrue(model.getNameVersionId().equalsIgnoreCase("94cac189-8d88-4d63-a194-f44214e080ff")); - assertTrue(model.getType().toString().equalsIgnoreCase("NAMED_QUERY")); - assertTrue(model.getDependentModelIds().size() == 4); - assertTrue(model.getDependentModelIds().contains("d09dd9da-0148-46cd-a947-591afc844d24")); - assertTrue(model.getDependentModelIds().contains("997fc7-fca1-451f-b953-9a1e6197b4d6")); - assertTrue(model.getDependentModelIds().contains("897df7ea-8938-42b0-bc57-46e913a4d93b")); - assertTrue(model.getDependentModelIds().contains("f2b24d95-c582-48d5-b2d6-c5b3a94ce812")); - } catch (Exception e) { - e.printStackTrace(); - assertTrue(false); - } - } -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.entity.model; + +import static org.junit.Assert.assertTrue; + +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; + +import org.junit.Test; +import org.openecomp.modelloader.entity.Artifact; + +public class ModelArtifactParserTest { + + @Test + public void testParseModelFileNoDeps() throws Exception { + final String MODEL_FILE = "src/test/resources/models/l3-network-widget.xml"; + + try { + byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE)); + + ModelArtifactParser parser = new ModelArtifactParser(); + List modelList = parser.parse(xmlBytes, "test-artifact"); + + assertTrue(modelList.size() == 1); + + ModelArtifact model = (ModelArtifact) modelList.get(0); + System.out.println(model.toString()); + + assertTrue(model.getModelInvariantId().equalsIgnoreCase("3d560d81-57d0-438b-a2a1-5334dba0651a")); + assertTrue(model.getType().toString().equalsIgnoreCase("MODEL")); + System.out.println(model.getDependentModelIds().size()); + assertTrue(model.getDependentModelIds().size() == 0); + } catch (Exception e) { + e.printStackTrace(); + assertTrue(false); + } + } + + @Test + public void testParseModelFileDeps() throws Exception { + final String MODEL_FILE = "src/test/resources/models/AAI-stellService-service-1.xml"; + + try { + byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE)); + + ModelArtifactParser parser = new ModelArtifactParser(); + List modelList = parser.parse(xmlBytes, "test-artifact"); + + assertTrue(modelList.size() == 1); + + ModelArtifact model = (ModelArtifact) modelList.get(0); + System.out.println(model.toString()); + + assertTrue(model.getModelInvariantId().equalsIgnoreCase("fedf9da3-6a74-4813-8fa2-221a98b0e7ad")); + assertTrue(model.getModelVerId().equalsIgnoreCase("e0373537-7f66-4094-9939-e2f5de6ff5f6")); + assertTrue(model.getType().toString().equalsIgnoreCase("MODEL")); + assertTrue(model.getDependentModelIds().size() == 3); + assertTrue(model.getDependentModelIds().contains("5c12984d-db0f-4300-a0e0-9791775cc40f|88bdbadf-db8a-490f-881e-c8effcbc3f66")); + assertTrue(model.getDependentModelIds().contains("959b7c09-9f34-4e5f-8b63-505381db176e|374d0899-bbc2-4403-9320-fe9bebef75c6")); + } catch (Exception e) { + e.printStackTrace(); + assertTrue(false); + } + } + + @Test + public void testParseCompleteModel() throws Exception { + final String MODEL_FILE = "src/test/resources/models/complete-model.xml"; + + try { + byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE)); + + ModelArtifactParser parser = new ModelArtifactParser(); + List modelList = parser.parse(xmlBytes, "test-artifact"); + + for (Artifact art : modelList) { + ModelArtifact model = (ModelArtifact) art; + System.out.println(model.toString()); + } + + assertTrue(modelList.size() == 5); + + ModelArtifact model1 = (ModelArtifact)modelList.get(0); + assertTrue(model1.getModelVerId().equalsIgnoreCase("88bdbadf-db8a-490f-881e-c8effcbc3f66")); + assertTrue(model1.getType().toString().equalsIgnoreCase("MODEL")); + assertTrue(model1.getDependentModelIds().size() == 1); + assertTrue(model1.getDependentModelIds().contains("3d560d81-57d0-438b-a2a1-5334dba0651a|9111f20f-e680-4001-b83f-19a2fc23bfc1")); + + ModelArtifact model4 = (ModelArtifact)modelList.get(4); + assertTrue(model4.getModelInvariantId().equalsIgnoreCase("fedf9da3-6a74-4813-8fa2-221a98b0e7ad")); + assertTrue(model4.getType().toString().equalsIgnoreCase("MODEL")); + assertTrue(model4.getDependentModelIds().size() == 3); + assertTrue(model4.getDependentModelIds().contains("5c12984d-db0f-4300-a0e0-9791775cc40f|88bdbadf-db8a-490f-881e-c8effcbc3f66")); + assertTrue(model4.getDependentModelIds().contains("82194af1-3c2c-485a-8f44-420e22a9eaa4|46b92144-923a-4d20-b85a-3cbd847668a9")); + } catch (Exception e) { + e.printStackTrace(); + assertTrue(false); + } + } + + @Test + public void testParseNamedQuery() throws Exception { + final String MODEL_FILE = "src/test/resources/models/named-query-wan-connector.xml"; + + try { + byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE)); + + ModelArtifactParser parser = new ModelArtifactParser(); + List modelList = parser.parse(xmlBytes, "test-artifact"); + + assertTrue(modelList.size() == 1); + + ModelArtifact model = (ModelArtifact) modelList.get(0); + System.out.println(model.toString()); + + assertTrue(model.getNameVersionId().equalsIgnoreCase("94cac189-8d88-4d63-a194-f44214e080ff")); + assertTrue(model.getType().toString().equalsIgnoreCase("NAMED_QUERY")); + assertTrue(model.getDependentModelIds().size() == 4); + assertTrue(model.getDependentModelIds().contains("d09dd9da-0148-46cd-a947-591afc844d24")); + assertTrue(model.getDependentModelIds().contains("997fc7-fca1-451f-b953-9a1e6197b4d6")); + assertTrue(model.getDependentModelIds().contains("897df7ea-8938-42b0-bc57-46e913a4d93b")); + assertTrue(model.getDependentModelIds().contains("f2b24d95-c582-48d5-b2d6-c5b3a94ce812")); + } catch (Exception e) { + e.printStackTrace(); + assertTrue(false); + } + } + + @Test + public void testParseModelFileInvalidArtifact() throws Exception { + final String MODEL_FILE = "src/test/resources/models/invalid-model.xml"; + + try { + byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE)); + + ModelArtifactParser parser = new ModelArtifactParser(); + List modelList = parser.parse(xmlBytes, "test-artifact"); + + assertTrue(modelList == null || modelList.isEmpty()); + } + catch (Exception e) { + e.printStackTrace(); + assertTrue(false); + } + } + + @Test + public void testParseModelFileIncompleteArtifact() throws Exception { + final String MODEL_FILE = "src/test/resources/models/incomplete-model.xml"; + + try { + byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE)); + + ModelArtifactParser parser = new ModelArtifactParser(); + List modelList = parser.parse(xmlBytes, "test-artifact"); + + assertTrue(modelList == null || modelList.isEmpty()); + } + catch (Exception e) { + e.printStackTrace(); + assertTrue(false); + } + } + + @Test + public void testParseModelFileIncompleteArtifacts() throws Exception { + final String MODEL_FILE = "src/test/resources/models/incomplete-models.xml"; + + try { + byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE)); + + ModelArtifactParser parser = new ModelArtifactParser(); + List modelList = parser.parse(xmlBytes, "test-artifact"); + + assertTrue(modelList == null || modelList.isEmpty()); + } + catch (Exception e) { + e.printStackTrace(); + assertTrue(false); + } + } + +} diff --git a/src/test/java/org/openecomp/modelloader/entity/model/ModelSorterTest.java b/src/test/java/org/openecomp/modelloader/entity/model/ModelSorterTest.java index dea537f..6a9cf88 100644 --- a/src/test/java/org/openecomp/modelloader/entity/model/ModelSorterTest.java +++ b/src/test/java/org/openecomp/modelloader/entity/model/ModelSorterTest.java @@ -1,133 +1,138 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.entity.model; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.junit.Test; -import org.openecomp.modelloader.entity.Artifact; - -public class ModelSorterTest { - - @Test - public void noModels() { - - List emptyList = Collections.emptyList(); - - ModelSorter sorter = new ModelSorter(); - sorter = new ModelSorter(); - - List sortedList = sorter.sort(emptyList); - assertNotNull(sortedList); - assertEquals(0, sortedList.size()); - - } - - @Test - public void singleModel() { - - List modelList = new ArrayList(); - - ModelArtifact model = new ModelArtifact(); - model.setNameVersionId("aaaaa"); - model.addDependentModelId("xyz"); - modelList.add(model); - - ModelSorter sorter = new ModelSorter(); - sorter = new ModelSorter(); - - List sortedList = sorter.sort(modelList); - assertNotNull(sortedList); - assertEquals(1, sortedList.size()); - - } - - /** - * - * depends on depends on B ------> A -------> C - * - * - * Input list = a, b, c Sorted list = c, a, b - * - */ - @Test - public void multipleModels() { - - List modelList = new ArrayList(); - - ModelArtifact aaaa = new ModelArtifact(); - aaaa.setNameVersionId("aaaa"); - aaaa.addDependentModelId("cccc"); - - ModelArtifact bbbb = new ModelArtifact(); - bbbb.setNameVersionId("bbbb"); - bbbb.addDependentModelId("aaaa"); - - ModelArtifact cccc = new ModelArtifact(); - cccc.setNameVersionId("cccc"); - - modelList.add(aaaa); - modelList.add(bbbb); - modelList.add(cccc); - - ModelSorter sorter = new ModelSorter(); - sorter = new ModelSorter(); - - List sortedList = sorter.sort(modelList); - assertNotNull(sortedList); - assertEquals(3, sortedList.size()); - - assertEquals(cccc, sortedList.get(0)); - assertEquals(aaaa, sortedList.get(1)); - assertEquals(bbbb, sortedList.get(2)); - } - - @Test(expected = RuntimeException.class) - public void circularDependency() { - - List modelList = new ArrayList(); - - ModelArtifact aaaa = new ModelArtifact(); - aaaa.setNameVersionId("aaaa"); - aaaa.addDependentModelId("bbbb"); - - ModelArtifact bbbb = new ModelArtifact(); - bbbb.setNameVersionId("bbbb"); - bbbb.addDependentModelId("aaaa"); - - modelList.add(aaaa); - modelList.add(bbbb); - - ModelSorter sorter = new ModelSorter(); - sorter = new ModelSorter(); - - List sortedList = sorter.sort(modelList); - assertNotNull(sortedList); - assertEquals(3, sortedList.size()); - - } - -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.entity.model; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.junit.Test; +import org.openecomp.modelloader.entity.Artifact; + +public class ModelSorterTest { + + @Test + public void noModels() { + + List emptyList = Collections.emptyList(); + + ModelSorter sorter = new ModelSorter(); + sorter = new ModelSorter(); + + List sortedList = sorter.sort(emptyList); + assertNotNull(sortedList); + assertEquals(0, sortedList.size()); + + } + + @Test + public void singleModel() { + + List modelList = new ArrayList(); + + ModelArtifact model = new ModelArtifact(); + model.setNameVersionId("aaaaa"); + model.addDependentModelId("xyz"); + modelList.add(model); + + ModelSorter sorter = new ModelSorter(); + sorter = new ModelSorter(); + + List sortedList = sorter.sort(modelList); + assertNotNull(sortedList); + assertEquals(1, sortedList.size()); + + } + + /** + * + * depends on depends on B ------> A -------> C + * + * + * Input list = a, b, c Sorted list = c, a, b + * + */ + @Test + public void multipleModels() { + + List modelList = new ArrayList(); + + ModelArtifact aaaa = new ModelArtifact(); + aaaa.setModelInvariantId("aaaa"); + aaaa.setModelVerId("mvaaaa"); + aaaa.addDependentModelId("cccc|mvcccc"); + + ModelArtifact bbbb = new ModelArtifact(); + bbbb.setModelInvariantId("bbbb"); + bbbb.setModelVerId("mvbbbb"); + bbbb.addDependentModelId("aaaa|mvaaaa"); + + ModelArtifact cccc = new ModelArtifact(); + cccc.setModelInvariantId("cccc"); + cccc.setModelVerId("mvcccc"); + + modelList.add(aaaa); + modelList.add(bbbb); + modelList.add(cccc); + + ModelSorter sorter = new ModelSorter(); + sorter = new ModelSorter(); + + List sortedList = sorter.sort(modelList); + assertNotNull(sortedList); + assertEquals(3, sortedList.size()); + + assertEquals(cccc, sortedList.get(0)); + assertEquals(aaaa, sortedList.get(1)); + assertEquals(bbbb, sortedList.get(2)); + } + + @Test(expected = RuntimeException.class) + public void circularDependency() { + + List modelList = new ArrayList(); + + ModelArtifact aaaa = new ModelArtifact(); + aaaa.setNameVersionId("aaaa"); + aaaa.addDependentModelId("bbbb"); + + ModelArtifact bbbb = new ModelArtifact(); + bbbb.setNameVersionId("bbbb"); + bbbb.addDependentModelId("aaaa"); + + modelList.add(aaaa); + modelList.add(bbbb); + + ModelSorter sorter = new ModelSorter(); + sorter = new ModelSorter(); + + List sortedList = sorter.sort(modelList); + assertNotNull(sortedList); + assertEquals(3, sortedList.size()); + + } + +} diff --git a/src/test/java/org/openecomp/modelloader/restclient/AAIRestClientTest.java b/src/test/java/org/openecomp/modelloader/restclient/AaiRestClientTest.java similarity index 92% rename from src/test/java/org/openecomp/modelloader/restclient/AAIRestClientTest.java rename to src/test/java/org/openecomp/modelloader/restclient/AaiRestClientTest.java index 08d7afe..dc6f9d6 100644 --- a/src/test/java/org/openecomp/modelloader/restclient/AAIRestClientTest.java +++ b/src/test/java/org/openecomp/modelloader/restclient/AaiRestClientTest.java @@ -1,119 +1,121 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.restclient; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; - -import org.openecomp.modelloader.config.ModelLoaderConfig; -import org.openecomp.modelloader.entity.ArtifactType; -import org.openecomp.modelloader.entity.model.ModelArtifact; - -public class AAIRestClientTest { - - // This test requires a running A&AI system. Uncomment to test locally. - /* - * @Test public void testRestClient() throws Exception { final String - * MODEL_FILE = "src/test/resources/models/vnf-model.xml"; - * - * Properties props = new Properties(); - * props.setProperty("ml.distribution.ARTIFACT_TYPES", - * "MODEL_INVENTORY_PROFILE,MODEL_QUERY_SPEC,VNF_CATALOG"); - * props.setProperty("ml.aai.BASE_URL", "https://127.0.0.1:4321"); - * props.setProperty("ml.aai.MODEL_URL", - * "/aai/v8/service-design-and-creation/models/model/"); - * props.setProperty("ml.aai.KEYSTORE_FILE", "aai-client-cert.p12"); - * props.setProperty("ml.aai.KEYSTORE_PASSWORD", - * "OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o"); - * - * ModelLoaderConfig config = new ModelLoaderConfig(props, ""); - * - * String payload = readFile(MODEL_FILE); System.out.println("FILE:" + - * payload); - * - * File xmlFile = new File(MODEL_FILE); DocumentBuilderFactory dbFactory = - * DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = - * dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(xmlFile); - * - * // Get the ID of the model String modelId = null; NodeList nodeList = - * doc.getDocumentElement().getChildNodes(); for (int i = 0; i < - * nodeList.getLength(); i++) { Node currentNode = nodeList.item(i); if - * (currentNode.getNodeName().equals("model-name-version-id")) { modelId = - * currentNode.getTextContent(); break; } } - * - * // Add the model try { ModelArtifact model = new ModelArtifact(); - * model.setNameVersionId(modelId); model.setType(ArtifactType.MODEL); - * model.setPayload(payload); - * - * AAIRestClient aaiClient = new AAIRestClient(config); - * - * // GET model System.out.println("Calling GET API ..."); ClientResponse - * getResponse = aaiClient.getResource(getURL(model, config), - * "example-trans-id-0", AAIRestClient.MimeType.XML); System.out.println( - * "GET result: " + getResponse.getStatus()); - * assertTrue(getResponse.getStatus() == - * Response.Status.NOT_FOUND.getStatusCode()); - * - * // Add the model System.out.println("Calling PUT API ..."); ClientResponse - * res = aaiClient.putResource(getURL(model, config), model.getPayload(), - * "example-trans-id-1", AAIRestClient.MimeType.XML); System.out.println( - * "PUT result: " + res.getStatus()); assertTrue(res.getStatus() == - * Response.Status.CREATED.getStatusCode()); - * - * // Delete the model System.out.println("Calling DELETE API ..."); res = - * aaiClient.getAndDeleteResource(getURL(model, config), - * "example-trans-id-3"); System.out.println("DELETE result: " + - * res.getStatus()); assertTrue(res.getStatus() == - * Response.Status.NO_CONTENT.getStatusCode()); } catch (Exception e) { - * e.printStackTrace(); } } - */ - - static String readFile(String path) throws IOException { - byte[] encoded = Files.readAllBytes(Paths.get(path)); - return new String(encoded); - } - - private String getURL(ModelArtifact model, ModelLoaderConfig config) { - String baseURL = config.getAaiBaseUrl().trim(); - String subURL = null; - if (model.getType().equals(ArtifactType.MODEL)) { - subURL = config.getAaiModelUrl().trim(); - } else { - subURL = config.getAaiNamedQueryUrl().trim(); - } - - if ((!baseURL.endsWith("/")) && (!subURL.startsWith("/"))) { - baseURL = baseURL + "/"; - } - - if (baseURL.endsWith("/") && subURL.startsWith("/")) { - baseURL = baseURL.substring(0, baseURL.length() - 1); - } - - if (!subURL.endsWith("/")) { - subURL = subURL + "/"; - } - - String url = baseURL + subURL + model.getNameVersionId(); - return url; - } -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.restclient; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + +import org.openecomp.modelloader.config.ModelLoaderConfig; +import org.openecomp.modelloader.entity.ArtifactType; +import org.openecomp.modelloader.entity.model.ModelArtifact; + +public class AaiRestClientTest { + + // This test requires a running A&AI system. Uncomment to test locally. + /* + * @Test public void testRestClient() throws Exception { final String + * MODEL_FILE = "src/test/resources/models/vnf-model.xml"; + * + * Properties props = new Properties(); + * props.setProperty("ml.distribution.ARTIFACT_TYPES", + * "MODEL_INVENTORY_PROFILE,MODEL_QUERY_SPEC,VNF_CATALOG"); + * props.setProperty("ml.aai.BASE_URL", "https://127.0.0.1:4321"); + * props.setProperty("ml.aai.MODEL_URL", + * "/aai/v8/service-design-and-creation/models/model/"); + * props.setProperty("ml.aai.KEYSTORE_FILE", "aai-client-cert.p12"); + * props.setProperty("ml.aai.KEYSTORE_PASSWORD", + * "OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o"); + * + * ModelLoaderConfig config = new ModelLoaderConfig(props, ""); + * + * String payload = readFile(MODEL_FILE); System.out.println("FILE:" + + * payload); + * + * File xmlFile = new File(MODEL_FILE); DocumentBuilderFactory dbFactory = + * DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = + * dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(xmlFile); + * + * // Get the ID of the model String modelId = null; NodeList nodeList = + * doc.getDocumentElement().getChildNodes(); for (int i = 0; i < + * nodeList.getLength(); i++) { Node currentNode = nodeList.item(i); if + * (currentNode.getNodeName().equals("model-name-version-id")) { modelId = + * currentNode.getTextContent(); break; } } + * + * // Add the model try { ModelArtifact model = new ModelArtifact(); + * model.setNameVersionId(modelId); model.setType(ArtifactType.MODEL); + * model.setPayload(payload); + * + * AAIRestClient aaiClient = new AAIRestClient(config); + * + * // GET model System.out.println("Calling GET API ..."); ClientResponse + * getResponse = aaiClient.getResource(getURL(model, config), + * "example-trans-id-0", AAIRestClient.MimeType.XML); System.out.println( + * "GET result: " + getResponse.getStatus()); + * assertTrue(getResponse.getStatus() == + * Response.Status.NOT_FOUND.getStatusCode()); + * + * // Add the model System.out.println("Calling PUT API ..."); ClientResponse + * res = aaiClient.putResource(getURL(model, config), model.getPayload(), + * "example-trans-id-1", AAIRestClient.MimeType.XML); System.out.println( + * "PUT result: " + res.getStatus()); assertTrue(res.getStatus() == + * Response.Status.CREATED.getStatusCode()); + * + * // Delete the model System.out.println("Calling DELETE API ..."); res = + * aaiClient.getAndDeleteResource(getURL(model, config), + * "example-trans-id-3"); System.out.println("DELETE result: " + + * res.getStatus()); assertTrue(res.getStatus() == + * Response.Status.NO_CONTENT.getStatusCode()); } catch (Exception e) { + * e.printStackTrace(); } } + */ + + static String readFile(String path) throws IOException { + byte[] encoded = Files.readAllBytes(Paths.get(path)); + return new String(encoded); + } + + private String getURL(ModelArtifact model, ModelLoaderConfig config) { + String baseURL = config.getAaiBaseUrl().trim(); + String subURL = null; + if (model.getType().equals(ArtifactType.MODEL)) { + subURL = config.getAaiModelUrl().trim(); + } else { + subURL = config.getAaiNamedQueryUrl().trim(); + } + + if ((!baseURL.endsWith("/")) && (!subURL.startsWith("/"))) { + baseURL = baseURL + "/"; + } + + if (baseURL.endsWith("/") && subURL.startsWith("/")) { + baseURL = baseURL.substring(0, baseURL.length() - 1); + } + + if (!subURL.endsWith("/")) { + subURL = subURL + "/"; + } + + String url = baseURL + subURL + model.getNameVersionId(); + return url; + } +} diff --git a/src/test/java/org/openecomp/modelloader/service/ModelLoaderServiceTest.java b/src/test/java/org/openecomp/modelloader/service/ModelLoaderServiceTest.java deleted file mode 100644 index c2893a9..0000000 --- a/src/test/java/org/openecomp/modelloader/service/ModelLoaderServiceTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.service; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.openecomp.modelloader.config.ModelLoaderConfig; -import org.openecomp.modelloader.notification.EventCallback; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import org.openecomp.sdc.api.IDistributionClient; -import org.openecomp.sdc.api.results.IDistributionClientResult; -import org.openecomp.sdc.impl.DistributionClientFactory; -import org.openecomp.sdc.utils.DistributionActionResultEnum; - -@PrepareForTest({ DistributionClientFactory.class }) -@RunWith(PowerMockRunner.class) -public class ModelLoaderServiceTest { - - /* - * //TODO this should be re-added once we come up with a strategy to fail - * gracefully - * - * @Test public void testNonExistentConfiguration(){ - * ModelLoaderService.CONFIG_LOCATION = "FAKELOCATION"; - * - * try{ new ModelLoaderService().start(); }catch(RuntimeException e){ - * assertTrue("Got unexpected message from error log", - * e.getMessage().contains("Failed to load configuration")); return; } - * - * fail("Expecting runtime exception"); } - */ - - @Test - public void testConfigureStartDistributionClient() { - PowerMockito.mockStatic(DistributionClientFactory.class); - - IDistributionClient mockClient = mock(IDistributionClient.class); - ModelLoaderConfig mockConfig = mock(ModelLoaderConfig.class); - - when(DistributionClientFactory.createDistributionClient()).thenReturn(mockClient); - - IDistributionClientResult result = mock(IDistributionClientResult.class); - - when(result.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS); - when(mockClient.init(Matchers. any(), Matchers. any())) - .thenReturn(result); - when(mockClient.start()).thenReturn(result); - - new ModelLoaderService().init(); - - // Validate that the client was initialized and started - verify(mockClient, times(1)).init(Matchers. any(), - Matchers. any()); - verify(mockClient, times(1)).start(); - } - - @Test - public void testInitializeButNotStarted() { - PowerMockito.mockStatic(DistributionClientFactory.class); - - IDistributionClient mockClient = mock(IDistributionClient.class); - ModelLoaderConfig mockConfig = mock(ModelLoaderConfig.class); - - DistributionActionResultEnum failureReason = DistributionActionResultEnum.ASDC_CONNECTION_FAILED; - - when(DistributionClientFactory.createDistributionClient()).thenReturn(mockClient); - - IDistributionClientResult initResult = mock(IDistributionClientResult.class); - when(initResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS); - IDistributionClientResult startResult = mock(IDistributionClientResult.class); - when(startResult.getDistributionActionResult()).thenReturn(failureReason); - - when(mockClient.init(Matchers. any(), Matchers. any())) - .thenReturn(initResult); - when(mockClient.start()).thenReturn(startResult); - - // TODO this should be re-added once we come up with a strategy to fail - // gracefully - /* - * try{ new ModelLoaderService().init(mockConfig); }catch(RuntimeException - * e){ assertTrue(e.getMessage().contains(failureReason.toString())); - * return; } - * - * fail("Expecting runtime exception with failure: " + - * failureReason.toString()); - */ - } -} diff --git a/src/test/java/org/openecomp/modelloader/util/JsonXmlConverterTest.java b/src/test/java/org/openecomp/modelloader/util/JsonXmlConverterTest.java index 4654c93..da89c78 100644 --- a/src/test/java/org/openecomp/modelloader/util/JsonXmlConverterTest.java +++ b/src/test/java/org/openecomp/modelloader/util/JsonXmlConverterTest.java @@ -1,79 +1,81 @@ -/*- - * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.modelloader.util; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.nio.file.Files; -import java.nio.file.Paths; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.junit.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class JsonXmlConverterTest { - - @Test - public void testConversion() throws Exception { - final String XML_MODEL_FILE = "src/test/resources/models/vnf-model.xml"; - final String JSON_MODEL_FILE = "src/test/resources/models/vnf-model.json"; - - try { - byte[] encoded = Files.readAllBytes(Paths.get(XML_MODEL_FILE)); - String originalXML = new String(encoded); - - assertFalse(JsonXmlConverter.isValidJson(originalXML)); - - encoded = Files.readAllBytes(Paths.get(JSON_MODEL_FILE)); - String originalJSON = new String(encoded); - - assertTrue(JsonXmlConverter.isValidJson(originalJSON)); - - String xmlFromJson = JsonXmlConverter.convertJsonToXml(originalJSON); - - // Spot check one of the attributes - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - Document doc = builder.parse(new ByteArrayInputStream(xmlFromJson.getBytes())); - NodeList nodeList = doc.getDocumentElement().getChildNodes(); - - String modelVid = "notFound"; - for (int i = 0; i < nodeList.getLength(); i++) { - Node currentNode = nodeList.item(i); - if (currentNode.getNodeName().equals("model-name-version-id")) { - modelVid = currentNode.getTextContent(); - break; - } - } - - assertTrue(modelVid.equals("model-vid")); - } catch (Exception e) { - e.printStackTrace(); - assertTrue(false); - } - } -} +/** + * ============LICENSE_START======================================================= + * Model Loader + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + */ +package org.openecomp.modelloader.util; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.ByteArrayInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.junit.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +public class JsonXmlConverterTest { + + @Test + public void testConversion() throws Exception { + final String XML_MODEL_FILE = "src/test/resources/models/l3-network-widget.xml"; + final String JSON_MODEL_FILE = "src/test/resources/models/l3-network-widget.json"; + + try { + byte[] encoded = Files.readAllBytes(Paths.get(XML_MODEL_FILE)); + String originalXML = new String(encoded); + + assertFalse(JsonXmlConverter.isValidJson(originalXML)); + + encoded = Files.readAllBytes(Paths.get(JSON_MODEL_FILE)); + String originalJSON = new String(encoded); + + assertTrue(JsonXmlConverter.isValidJson(originalJSON)); + + String xmlFromJson = JsonXmlConverter.convertJsonToXml(originalJSON); + + // Spot check one of the attributes + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + Document doc = builder.parse(new ByteArrayInputStream(xmlFromJson.getBytes())); + NodeList nodeList = doc.getDocumentElement().getChildNodes(); + + String modelVid = "notFound"; + for (int i = 0; i < nodeList.getLength(); i++) { + Node currentNode = nodeList.item(i); + if (currentNode.getNodeName().equals("model-invariant-id")) { + modelVid = currentNode.getTextContent(); + break; + } + } + + assertTrue(modelVid.equals("3d560d81-57d0-438b-a2a1-5334dba0651a")); + } catch (Exception e) { + e.printStackTrace(); + assertTrue(false); + } + } +} diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml index 1252135..3f0fb7a 100644 --- a/src/test/resources/logback-test.xml +++ b/src/test/resources/logback-test.xml @@ -1,37 +1,37 @@ - - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - - + ============LICENSE_END========================================================= + --> + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + diff --git a/src/test/resources/model-loader-empty-auth-password.properties b/src/test/resources/model-loader-empty-auth-password.properties index 69f3da1..34432a4 100644 --- a/src/test/resources/model-loader-empty-auth-password.properties +++ b/src/test/resources/model-loader-empty-auth-password.properties @@ -1,43 +1,43 @@ -### +### # ============LICENSE_START======================================================= # MODEL LOADER SERVICE # ================================================================================ # Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. # ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and # limitations under the License. -# ============LICENSE_END========================================================= -### - -# Model Loader Distribution Client Configuration -ml.distribution.ACTIVE_SERVER_TLS_AUTH=false -ml.distribution.ASDC_ADDRESS= -ml.distribution.CONSUMER_GROUP=aai-ml-group-test -ml.distribution.CONSUMER_ID=aai-ml-id-test -ml.distribution.ENVIRONMENT_NAME= -ml.distribution.KEYSTORE_PASSWORD= -ml.distribution.KEYSTORE_FILE=asdc-client.jks -ml.distribution.PASSWORD= -ml.distribution.POLLING_INTERVAL=30 -ml.distribution.POLLING_TIMEOUT=20 -ml.distribution.USER=ci -ml.distribution.ARTIFACT_TYPES=MODEL_INVENTORY_PROFILE,MODEL_QUERY_SPEC,VNF_CATALOG - -# Model Loader AAI REST Client Configuration -ml.aai.BASE_URL= -ml.aai.MODEL_URL=/aai/v8/service-design-and-creation/models/model/ -ml.aai.NAMED_QUERY_URL=/aai/v8/service-design-and-creation/named-queries/named-query/ -ml.aai.VNF_IMAGE_URL=/aai/v8/service-design-and-creation/vnf-images -ml.aai.KEYSTORE_FILE=aai-client-cert.p12 -ml.aai.KEYSTORE_PASSWORD= -ml.aai.AUTH_USER=ModelLoader -ml.aai.AUTH_PASSWORD= +# ============LICENSE_END========================================================= +### + +# Model Loader Distribution Client Configuration +ml.distribution.ACTIVE_SERVER_TLS_AUTH=false +ml.distribution.ASDC_ADDRESS= +ml.distribution.CONSUMER_GROUP=aai-ml-group-test +ml.distribution.CONSUMER_ID=aai-ml-id-test +ml.distribution.ENVIRONMENT_NAME= +ml.distribution.KEYSTORE_PASSWORD= +ml.distribution.KEYSTORE_FILE=asdc-client.jks +ml.distribution.PASSWORD= +ml.distribution.POLLING_INTERVAL=30 +ml.distribution.POLLING_TIMEOUT=20 +ml.distribution.USER=ci +ml.distribution.ARTIFACT_TYPES=MODEL_INVENTORY_PROFILE,MODEL_QUERY_SPEC,VNF_CATALOG + +# Model Loader AAI REST Client Configuration +ml.aai.BASE_URL= +ml.aai.MODEL_URL=/aai/v8/service-design-and-creation/models/model/ +ml.aai.NAMED_QUERY_URL=/aai/v8/service-design-and-creation/named-queries/named-query/ +ml.aai.VNF_IMAGE_URL=/aai/v8/service-design-and-creation/vnf-images +ml.aai.KEYSTORE_FILE=aai-client-cert.p12 +ml.aai.KEYSTORE_PASSWORD= +ml.aai.AUTH_USER=ModelLoader +ml.aai.AUTH_PASSWORD= diff --git a/src/test/resources/model-loader-no-auth-password.properties b/src/test/resources/model-loader-no-auth-password.properties index 8d59db1..035d3e8 100644 --- a/src/test/resources/model-loader-no-auth-password.properties +++ b/src/test/resources/model-loader-no-auth-password.properties @@ -1,41 +1,41 @@ -### +### # ============LICENSE_START======================================================= # MODEL LOADER SERVICE # ================================================================================ # Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. # ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and # limitations under the License. -# ============LICENSE_END========================================================= -### - -# Model Loader Distribution Client Configuration -ml.distribution.ACTIVE_SERVER_TLS_AUTH=false -ml.distribution.ASDC_ADDRESS= -ml.distribution.CONSUMER_GROUP=aai-ml-group-test -ml.distribution.CONSUMER_ID=aai-ml-id-test -ml.distribution.ENVIRONMENT_NAME= -ml.distribution.KEYSTORE_PASSWORD= -ml.distribution.KEYSTORE_FILE=asdc-client.jks -ml.distribution.PASSWORD= -ml.distribution.POLLING_INTERVAL=30 -ml.distribution.POLLING_TIMEOUT=20 -ml.distribution.USER=ci -ml.distribution.ARTIFACT_TYPES=MODEL_INVENTORY_PROFILE,MODEL_QUERY_SPEC,VNF_CATALOG - -# Model Loader AAI REST Client Configuration -ml.aai.BASE_URL= -ml.aai.MODEL_URL=/aai/v8/service-design-and-creation/models/model/ -ml.aai.NAMED_QUERY_URL=/aai/v8/service-design-and-creation/named-queries/named-query/ -ml.aai.VNF_IMAGE_URL=/aai/v8/service-design-and-creation/vnf-images -ml.aai.KEYSTORE_FILE=aai-client-cert.p12 -ml.aai.KEYSTORE_PASSWORD= +# ============LICENSE_END========================================================= +### + +# Model Loader Distribution Client Configuration +ml.distribution.ACTIVE_SERVER_TLS_AUTH=false +ml.distribution.ASDC_ADDRESS= +ml.distribution.CONSUMER_GROUP=aai-ml-group-test +ml.distribution.CONSUMER_ID=aai-ml-id-test +ml.distribution.ENVIRONMENT_NAME= +ml.distribution.KEYSTORE_PASSWORD= +ml.distribution.KEYSTORE_FILE=asdc-client.jks +ml.distribution.PASSWORD= +ml.distribution.POLLING_INTERVAL=30 +ml.distribution.POLLING_TIMEOUT=20 +ml.distribution.USER=ci +ml.distribution.ARTIFACT_TYPES=MODEL_INVENTORY_PROFILE,MODEL_QUERY_SPEC,VNF_CATALOG + +# Model Loader AAI REST Client Configuration +ml.aai.BASE_URL= +ml.aai.MODEL_URL=/aai/v8/service-design-and-creation/models/model/ +ml.aai.NAMED_QUERY_URL=/aai/v8/service-design-and-creation/named-queries/named-query/ +ml.aai.VNF_IMAGE_URL=/aai/v8/service-design-and-creation/vnf-images +ml.aai.KEYSTORE_FILE=aai-client-cert.p12 +ml.aai.KEYSTORE_PASSWORD= diff --git a/src/test/resources/model-loader.properties b/src/test/resources/model-loader.properties index 69f3da1..34432a4 100644 --- a/src/test/resources/model-loader.properties +++ b/src/test/resources/model-loader.properties @@ -1,43 +1,43 @@ -### +### # ============LICENSE_START======================================================= # MODEL LOADER SERVICE # ================================================================================ # Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. # ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and # limitations under the License. -# ============LICENSE_END========================================================= -### - -# Model Loader Distribution Client Configuration -ml.distribution.ACTIVE_SERVER_TLS_AUTH=false -ml.distribution.ASDC_ADDRESS= -ml.distribution.CONSUMER_GROUP=aai-ml-group-test -ml.distribution.CONSUMER_ID=aai-ml-id-test -ml.distribution.ENVIRONMENT_NAME= -ml.distribution.KEYSTORE_PASSWORD= -ml.distribution.KEYSTORE_FILE=asdc-client.jks -ml.distribution.PASSWORD= -ml.distribution.POLLING_INTERVAL=30 -ml.distribution.POLLING_TIMEOUT=20 -ml.distribution.USER=ci -ml.distribution.ARTIFACT_TYPES=MODEL_INVENTORY_PROFILE,MODEL_QUERY_SPEC,VNF_CATALOG - -# Model Loader AAI REST Client Configuration -ml.aai.BASE_URL= -ml.aai.MODEL_URL=/aai/v8/service-design-and-creation/models/model/ -ml.aai.NAMED_QUERY_URL=/aai/v8/service-design-and-creation/named-queries/named-query/ -ml.aai.VNF_IMAGE_URL=/aai/v8/service-design-and-creation/vnf-images -ml.aai.KEYSTORE_FILE=aai-client-cert.p12 -ml.aai.KEYSTORE_PASSWORD= -ml.aai.AUTH_USER=ModelLoader -ml.aai.AUTH_PASSWORD= +# ============LICENSE_END========================================================= +### + +# Model Loader Distribution Client Configuration +ml.distribution.ACTIVE_SERVER_TLS_AUTH=false +ml.distribution.ASDC_ADDRESS= +ml.distribution.CONSUMER_GROUP=aai-ml-group-test +ml.distribution.CONSUMER_ID=aai-ml-id-test +ml.distribution.ENVIRONMENT_NAME= +ml.distribution.KEYSTORE_PASSWORD= +ml.distribution.KEYSTORE_FILE=asdc-client.jks +ml.distribution.PASSWORD= +ml.distribution.POLLING_INTERVAL=30 +ml.distribution.POLLING_TIMEOUT=20 +ml.distribution.USER=ci +ml.distribution.ARTIFACT_TYPES=MODEL_INVENTORY_PROFILE,MODEL_QUERY_SPEC,VNF_CATALOG + +# Model Loader AAI REST Client Configuration +ml.aai.BASE_URL= +ml.aai.MODEL_URL=/aai/v8/service-design-and-creation/models/model/ +ml.aai.NAMED_QUERY_URL=/aai/v8/service-design-and-creation/named-queries/named-query/ +ml.aai.VNF_IMAGE_URL=/aai/v8/service-design-and-creation/vnf-images +ml.aai.KEYSTORE_FILE=aai-client-cert.p12 +ml.aai.KEYSTORE_PASSWORD= +ml.aai.AUTH_USER=ModelLoader +ml.aai.AUTH_PASSWORD= diff --git a/src/test/resources/models/AAI-Testvsp..vmme_cinder..module-1-resource-1.xml b/src/test/resources/models/AAI-Testvsp..vmme_cinder..module-1-resource-1.xml new file mode 100644 index 0000000..7bd1073 --- /dev/null +++ b/src/test/resources/models/AAI-Testvsp..vmme_cinder..module-1-resource-1.xml @@ -0,0 +1,52 @@ + + + + 5a2aac99-ffe8-415f-9242-420ed10da23e + resource + + + 29d3fc43-4ff2-4e5c-acd0-7370f5b2715a + Testvsp..vmme_cinder..module-1 + 1 + + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + c00563ae-812b-4e62-8330-7c4d0f47088a + + + model.model-invariant-id + ef86f9c5-2165-44f3-8fc3-96018b609ea5 + + + + + + + + diff --git a/src/test/resources/models/AAI-Testvsp..vmme_small_ecomp..module-0-resource-1.xml b/src/test/resources/models/AAI-Testvsp..vmme_small_ecomp..module-0-resource-1.xml new file mode 100644 index 0000000..8fe5319 --- /dev/null +++ b/src/test/resources/models/AAI-Testvsp..vmme_small_ecomp..module-0-resource-1.xml @@ -0,0 +1,180 @@ + + + + 1e8fdfc0-03cf-4742-b060-dab818954d67 + resource + + + da6769f0-aa58-4e90-b2c9-664c2630d131 + Testvsp..vmme_small_ecomp..module-0 + 1 + + + + F + unbounded + + + F + unbounded + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + f6a038c2-820c-42ba-8c2b-375e24e8f932 + + + model.model-invariant-id + 3f4c7204-739b-4bbb-87a7-8a6856439c90 + + + + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + abcc54bc-bb74-49dc-9043-7f7171707545 + + + model.model-invariant-id + 97c26c99-6870-44c1-8a07-1d900d3f4ce6 + + + + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + 36200fb5-f251-4f5d-a520-7c5ad5c2cd4b + + + model.model-invariant-id + bace8d1c-a261-4041-9e37-823117415d0f + + + + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + a32613fd-18b9-459e-aab8-fffb3912966a + + + model.model-invariant-id + cea0a982-8d55-4093-921e-418fbccf7060 + + + + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + 5761e0a7-c6df-4d8a-9ebd-b8f445054dec + + + model.model-invariant-id + 96129eb9-f0de-4e05-8af2-73146473f766 + + + + + + + + model-ver + + model-ver.model-version-id + 8ecb2c5d-7176-4317-a255-26274edfdd53 + + + model.model-invariant-id + ff69d4e0-a8e8-4108-bdb0-dd63217e63c7 + + + + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + 9111f20f-e680-4001-b83f-19a2fc23bfc1 + + + model.model-invariant-id + 3d560d81-57d0-438b-a2a1-5334dba0651a + + + + + + + + model-ver + + model-ver.model-version-id + c00563ae-812b-4e62-8330-7c4d0f47088a + + + model.model-invariant-id + ef86f9c5-2165-44f3-8fc3-96018b609ea5 + + + + + + + + diff --git a/src/test/resources/models/AAI-VL-resource-1.xml b/src/test/resources/models/AAI-VL-resource-1.xml new file mode 100644 index 0000000..98941ad --- /dev/null +++ b/src/test/resources/models/AAI-VL-resource-1.xml @@ -0,0 +1,52 @@ + + + + 5c12984d-db0f-4300-a0e0-9791775cc40f + resource + + + 88bdbadf-db8a-490f-881e-c8effcbc3f66 + VL + 1 + Virtual link (VL) describes the basic topology of the connectivity as well as other required parameters (e.g. bandwidth and QoS class). + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + 9111f20f-e680-4001-b83f-19a2fc23bfc1 + + + model.model-invariant-id + 3d560d81-57d0-438b-a2a1-5334dba0651a + + + + + + + + diff --git a/src/test/resources/models/AAI-stellService-service-1.xml b/src/test/resources/models/AAI-stellService-service-1.xml new file mode 100644 index 0000000..378b09e --- /dev/null +++ b/src/test/resources/models/AAI-stellService-service-1.xml @@ -0,0 +1,89 @@ + + + + fedf9da3-6a74-4813-8fa2-221a98b0e7ad + service + + + e0373537-7f66-4094-9939-e2f5de6ff5f6 + stellService + 1 + fd + + + F + unbounded + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + 88bdbadf-db8a-490f-881e-c8effcbc3f66 + + + model.model-invariant-id + 5c12984d-db0f-4300-a0e0-9791775cc40f + + + + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + 374d0899-bbc2-4403-9320-fe9bebef75c6 + + + model.model-invariant-id + 959b7c09-9f34-4e5f-8b63-505381db176e + + + + + + + + model-ver + + model-ver.model-version-id + 46b92144-923a-4d20-b85a-3cbd847668a9 + + + model.model-invariant-id + 82194af1-3c2c-485a-8f44-420e22a9eaa4 + + + + + + + + diff --git a/src/test/resources/models/AAI-testvsp-resource-1.xml b/src/test/resources/models/AAI-testvsp-resource-1.xml new file mode 100644 index 0000000..c9a70ff --- /dev/null +++ b/src/test/resources/models/AAI-testvsp-resource-1.xml @@ -0,0 +1,89 @@ + + + + 959b7c09-9f34-4e5f-8b63-505381db176e + resource + + + 374d0899-bbc2-4403-9320-fe9bebef75c6 + testvsp + 1 + nkjlkl + + + F + unbounded + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + da6769f0-aa58-4e90-b2c9-664c2630d131 + + + model.model-invariant-id + 1e8fdfc0-03cf-4742-b060-dab818954d67 + + + + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + 29d3fc43-4ff2-4e5c-acd0-7370f5b2715a + + + model.model-invariant-id + 5a2aac99-ffe8-415f-9242-420ed10da23e + + + + + + + + model-ver + + model-ver.model-version-id + 93a6166f-b3d5-4f06-b4ba-aed48d009ad9 + + + model.model-invariant-id + acc6edd8-a8d4-4b93-afaa-0994068be14c + + + + + + + + diff --git a/src/test/resources/models/complete-model.xml b/src/test/resources/models/complete-model.xml index 45e849b..394c073 100644 --- a/src/test/resources/models/complete-model.xml +++ b/src/test/resources/models/complete-model.xml @@ -1,143 +1,384 @@ - - - - - 997fc7-fca1-451f-b953-9a1e6197b4d6 - - widget - vdc - 897df7ea-8938-42b0-bc57-46e913a4d93b - v1.0 - 1463175188 - - - model-element - https://localhost:8443/aai/v8/service-design-and-creation/model-elements/model-element/ccb3a5a4-1722-4213-8785-2b6b5527d453/ - - - model-element.model-element-uuid - - ccb3a5a4-1722-4213-8785-2b6b5527d453 - - - - model-element.model-element-uuid - - df2e4cc0-18ca-4046-9c1b-2abec86a58d6 - - - - model.model-name-version-id - 93d9d45d-7eec-4371-9083-675e4c353de3 - - - - - - - 8da97b81-e0e9-4157-a4cd-af3ba52871d6 - - resource - vDbe - 77b83c95-7707-4624-8bfe-9110b9c2dc88 - v1.0 - 1463175188 - - - model-element - https://localhost:8443/aai/v8/service-design-and-creation/model-elements/model-element/fc3a2260-d0ee-4c8e-b7e9-74791d7c5721/ - - - model-element.model-element-uuid - - fc3a2260-d0ee-4c8e-b7e9-74791d7c5721 - - - - element-choice-set.element-choice-set-uuid - - 646ee687-1475-419d-bd10-f3760d5430dc - - - - constrained-element-set.constrained-element-set-uuid - - 999 - - - model-element.model-element-uuid - - df2e4cc0-18ca-4046-9c1b-2abec86a58d6 - - - - model.model-name-version-id - 93d9d45d-7eec-4371-9083-675e4c353de3 - - - - - - - f2b24d95-c582-48d5-b2d6-c5b3a94ce812 - - widget - pserver - a033a95f-93af-4dc6-811e-f818baf13ef1 - v1.0 - 1463175178 - - - model-element - https://localhost:8443/aai/v8/service-design-and-creation/model-elements/model-element/5eab2693-78ec-446a-afe4-14332e348246/ - - - model-element.model-element-uuid - - 5eab2693-78ec-446a-afe4-14332e348246 - - - - model.model-name-version-id - 35be1acf-1298-48c6-a128-66850083b8bd - - - - - model-element - https://localhost:8443/aai/v8/service-design-and-creation/model-elements/model-element/f7659dac-6311-45b6-b483-60b39364a85a/ - - - model-element.model-element-uuid - - f7659dac-6311-45b6-b483-60b39364a85a - - - - model.model-name-version-id - 759dbd4a-2473-46f3-a932-48d987c9b4a1 - - - - - - - + ============LICENSE_END========================================================= + --> + + + + 5c12984d-db0f-4300-a0e0-9791775cc40f + resource + + + 88bdbadf-db8a-490f-881e-c8effcbc3f66 + VL + 1 + Virtual link (VL) describes the basic topology of the connectivity as well as other required parameters (e.g. bandwidth and QoS class). + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + 9111f20f-e680-4001-b83f-19a2fc23bfc1 + + + model.model-invariant-id + 3d560d81-57d0-438b-a2a1-5334dba0651a + + + + + + + + + + 1e8fdfc0-03cf-4742-b060-dab818954d67 + resource + + + da6769f0-aa58-4e90-b2c9-664c2630d131 + Testvsp..vmme_small_ecomp..module-0 + 1 + + + + F + unbounded + + + F + unbounded + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + f6a038c2-820c-42ba-8c2b-375e24e8f932 + + + model.model-invariant-id + 3f4c7204-739b-4bbb-87a7-8a6856439c90 + + + + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + abcc54bc-bb74-49dc-9043-7f7171707545 + + + model.model-invariant-id + 97c26c99-6870-44c1-8a07-1d900d3f4ce6 + + + + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + 36200fb5-f251-4f5d-a520-7c5ad5c2cd4b + + + model.model-invariant-id + bace8d1c-a261-4041-9e37-823117415d0f + + + + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + a32613fd-18b9-459e-aab8-fffb3912966a + + + model.model-invariant-id + cea0a982-8d55-4093-921e-418fbccf7060 + + + + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + 5761e0a7-c6df-4d8a-9ebd-b8f445054dec + + + model.model-invariant-id + 96129eb9-f0de-4e05-8af2-73146473f766 + + + + + + + + model-ver + + model-ver.model-version-id + 8ecb2c5d-7176-4317-a255-26274edfdd53 + + + model.model-invariant-id + ff69d4e0-a8e8-4108-bdb0-dd63217e63c7 + + + + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + 9111f20f-e680-4001-b83f-19a2fc23bfc1 + + + model.model-invariant-id + 3d560d81-57d0-438b-a2a1-5334dba0651a + + + + + + + + model-ver + + model-ver.model-version-id + c00563ae-812b-4e62-8330-7c4d0f47088a + + + model.model-invariant-id + ef86f9c5-2165-44f3-8fc3-96018b609ea5 + + + + + + + + + + 5a2aac99-ffe8-415f-9242-420ed10da23e + resource + + + 29d3fc43-4ff2-4e5c-acd0-7370f5b2715a + Testvsp..vmme_cinder..module-1 + 1 + + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + c00563ae-812b-4e62-8330-7c4d0f47088a + + + model.model-invariant-id + ef86f9c5-2165-44f3-8fc3-96018b609ea5 + + + + + + + + + + 959b7c09-9f34-4e5f-8b63-505381db176e + resource + + + 374d0899-bbc2-4403-9320-fe9bebef75c6 + testvsp + 1 + nkjlkl + + + F + unbounded + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + da6769f0-aa58-4e90-b2c9-664c2630d131 + + + model.model-invariant-id + 1e8fdfc0-03cf-4742-b060-dab818954d67 + + + + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + 29d3fc43-4ff2-4e5c-acd0-7370f5b2715a + + + model.model-invariant-id + 5a2aac99-ffe8-415f-9242-420ed10da23e + + + + + + + + model-ver + + model-ver.model-version-id + 93a6166f-b3d5-4f06-b4ba-aed48d009ad9 + + + model.model-invariant-id + acc6edd8-a8d4-4b93-afaa-0994068be14c + + + + + + + + + + fedf9da3-6a74-4813-8fa2-221a98b0e7ad + service + + + e0373537-7f66-4094-9939-e2f5de6ff5f6 + stellService + 1 + fd + + + F + unbounded + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + 88bdbadf-db8a-490f-881e-c8effcbc3f66 + + + model.model-invariant-id + 5c12984d-db0f-4300-a0e0-9791775cc40f + + + + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + 374d0899-bbc2-4403-9320-fe9bebef75c6 + + + model.model-invariant-id + 959b7c09-9f34-4e5f-8b63-505381db176e + + + + + + + + model-ver + + model-ver.model-version-id + 46b92144-923a-4d20-b85a-3cbd847668a9 + + + model.model-invariant-id + 82194af1-3c2c-485a-8f44-420e22a9eaa4 + + + + + + + + + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/test/resources/models/incomplete-model.xml similarity index 56% rename from src/main/webapp/WEB-INF/web.xml rename to src/test/resources/models/incomplete-model.xml index c256b26..b30d4d7 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/test/resources/models/incomplete-model.xml @@ -1,40 +1,37 @@ - - - - - model-loader - - - - org.springframework.web.context.ContextLoaderListener - - - - - rest - org.springframework.web.servlet.DispatcherServlet - 1 - - - rest - / - - + ============LICENSE_END========================================================= + --> + + + resource + + + VL + 1 + Virtual link (VL) describes the basic topology of the connectivity as well as other required parameters (e.g. bandwidth and QoS class). + + + F + unbounded + + + + + + diff --git a/src/test/resources/models/incomplete-models.xml b/src/test/resources/models/incomplete-models.xml new file mode 100644 index 0000000..56b10de --- /dev/null +++ b/src/test/resources/models/incomplete-models.xml @@ -0,0 +1,50 @@ + + + + + 3d560d81-57d0-438b-a2a1-5334dba0651a + widget + + + 9111f20f-e680-4001-b83f-19a2fc23bfc1 + 1.0 + l3-network + + + + + resource + + + VL + 1 + Virtual link (VL) describes the basic topology of the connectivity as well as other required parameters (e.g. bandwidth and QoS class). + + + F + unbounded + + + + + + + diff --git a/src/test/resources/models/invalid-model.xml b/src/test/resources/models/invalid-model.xml new file mode 100644 index 0000000..906cd21 --- /dev/null +++ b/src/test/resources/models/invalid-model.xml @@ -0,0 +1,51 @@ + + + + 5c12984d-db0f-4300-a0e0-9791775cc40f + resource + + + 88bdbadf-db8a-490f-881e-c8effcbc3f66 + VL + 1 + Virtual link (VL) describes the basic topology of the connectivity as well as other required parameters (e.g. bandwidth and QoS class). + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + 9111f20f-e680-4001-b83f-19a2fc23bfc1 + + + model.model-invariant-id + 3d560d81-57d0-438b-a2a1-5334dba0651a + + + + + + + diff --git a/src/test/resources/models/l3-network-widget.json b/src/test/resources/models/l3-network-widget.json new file mode 100644 index 0000000..22304ac --- /dev/null +++ b/src/test/resources/models/l3-network-widget.json @@ -0,0 +1,14 @@ +{ + "model": + { + "model-invariant-id" : "3d560d81-57d0-438b-a2a1-5334dba0651a", + "model-type" : "widget", + "model-vers" : { + "model-ver" : [ { + "model-version-id" : "9111f20f-e680-4001-b83f-19a2fc23bfc1", + "model-version" : "1.0", + "model-name" : "l3-network" + } ] + } + } +} diff --git a/src/main/webapp/WEB-INF/applicationContext.xml b/src/test/resources/models/l3-network-widget.xml similarity index 61% rename from src/main/webapp/WEB-INF/applicationContext.xml rename to src/test/resources/models/l3-network-widget.xml index 08a88e6..1e50300 100644 --- a/src/main/webapp/WEB-INF/applicationContext.xml +++ b/src/test/resources/models/l3-network-widget.xml @@ -1,29 +1,31 @@ - - - - - + ============LICENSE_END========================================================= + --> + + + 3d560d81-57d0-438b-a2a1-5334dba0651a + widget + + + 9111f20f-e680-4001-b83f-19a2fc23bfc1 + 1.0 + l3-network + + + diff --git a/src/test/resources/models/named-query-wan-connector.xml b/src/test/resources/models/named-query-wan-connector.xml index 5606cf8..51047df 100644 --- a/src/test/resources/models/named-query-wan-connector.xml +++ b/src/test/resources/models/named-query-wan-connector.xml @@ -1,90 +1,90 @@ - - - - 94cac189-8d88-4d63-a194-f44214e080ff - - wan-connector - v1.0 - Named Query - Wan Connector - - - - - model - - - model.model-name-version-id - d09dd9da-0148-46cd-a947-591afc844d24 - - - - - - - - - model - - - model.model-name-version-id - 997fc7-fca1-451f-b953-9a1e6197b4d6 - - - - - - - - - model - - - model.model-name-version-id - - 897df7ea-8938-42b0-bc57-46e913a4d93b - - - - - - - - - model - - - model.model-name-version-id - - f2b24d95-c582-48d5-b2d6-c5b3a94ce812 - - - - - - - - - - - - - - + ============LICENSE_END========================================================= + --> + + + 94cac189-8d88-4d63-a194-f44214e080ff + + wan-connector + v1.0 + Named Query - Wan Connector + + + + + model + + + model.model-invariant-id + d09dd9da-0148-46cd-a947-591afc844d24 + + + + + + + + + model + + + model.model-invariant-id + 997fc7-fca1-451f-b953-9a1e6197b4d6 + + + + + + + + + model + + + model.model-invariant-id + + 897df7ea-8938-42b0-bc57-46e913a4d93b + + + + + + + + + model + + + model.model-invariant-id + + f2b24d95-c582-48d5-b2d6-c5b3a94ce812 + + + + + + + + + + + + + + diff --git a/src/test/resources/models/vnf-model.json b/src/test/resources/models/vnf-model.json deleted file mode 100644 index 5bebe59..0000000 --- a/src/test/resources/models/vnf-model.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "model": - { - "model-name-version-id":"model-vid", - "model-type":"widget", - "model-version":"v1.0", - "model-id":"model-id", - "model-name":"generic-vnf" - } -} diff --git a/src/test/resources/models/wan-connector-model.xml b/src/test/resources/models/wan-connector-model.xml deleted file mode 100644 index c8a434b..0000000 --- a/src/test/resources/models/wan-connector-model.xml +++ /dev/null @@ -1,185 +0,0 @@ - - - - e4a9901b-6c94-4e07-b8d8-b877d3df554c - service - test-model - v1.0 - 93d9d45d-7eec-4371-9083-675e4c353de3 - - desc - - - a - vpn-id - - - b - product - - - - - true - unbounded - - - model - - - model.model-name-version-id - d09dd9da-0148-46cd-a947-591afc844d24 - - - - - - - true - unbounded - - - model - - - model.model-name-version-id - 997fc7-fca1-451f-b953-9a1e6197b4d6 - - - - - - - true - unbounded - - - model - - - model.model-name-version-id - - ae16244f-4d29-4801-a559-e25f2db2a4c3 - - - - - - - - logical-link - 999 - - combination - AND - - - A - 1 - - - unbounded - false - - - model - - - model.model-name-version-id - - 759dbd4a-2473-46f3-a932-48d987c9b4a1 - - - - - - l-interface|p-interface|pserver - - - - - - - B - 1 - - - unbounded - false - - - model - - - model.model-name-version-id - - 8da97b81-e0e9-4157-a4cd-af3ba52871d6 - - - - - - - unbounded - false - - - model - - - model.model-name-version-id - - a6d9de88-4046-4b78-a59e-5691243d292a - - - - - - - unbounded - false - - - model - - - model.model-name-version-id - - 35be1acf-1298-48c6-a128-66850083b8bd - - - - - - - - - - - - - - - - - - - diff --git a/src/test/resources/vnfcatalogexample.xml b/src/test/resources/vnfcatalogexample.xml index c7ba530..0348f71 100644 --- a/src/test/resources/vnfcatalogexample.xml +++ b/src/test/resources/vnfcatalogexample.xml @@ -1,149 +1,149 @@ - - - - - FortiGate-VM00 - FW - - FORTINET - FortiGate-VM00 - VM00 - - - 1 - 1 - 1 - - - 1 - GB - 1 - 1 - - - 2 - GB - 2 - 32 - - - 5.2.7 - 0 - IMAGE - 1c59a521885c465004456f74d003726c - test3 - - - 5.2.5 - 1 - IMAGE - C4D2CBE51669796E48623E006782F7DC - test2 - - - 5.2.4 - 2 - IMAGE - 4987E1E743FD641C879E1D3C5D50BCE0 - test1 - - - APPID - - - IPS-IDS - - - URLF - - - Anti-Virus - - - FortiGate-VM00 - FALSE - - - - FortiGate-VM01 - FW - - FORTINET - FortiGate-VM01 - VM01 - - - 1 - 1 - 1 - - - 2 - GB - 1 - 2 - - - 2 - GB - 2 - 32 - - - 5.2.7 - 0 - IMAGE - 1c59a521885c465004456f74d003726c - software file name 3 - - - 5.2.5 - 1 - IMAGE - C4D2CBE51669796E48623E006782F7DC - software file name 2 - - - 5.2.4 - 2 - IMAGE - 4987E1E743FD641C879E1D3C5D50BCE0 - software file name - - - APPID - - - IPS-IDS - - - URLF - - - Anti-Virus - - - license group - FALSE - - - - + ============LICENSE_END========================================================= + --> + + + + FortiGate-VM00 + FW + + FORTINET + FortiGate-VM00 + VM00 + + + 1 + 1 + 1 + + + 1 + GB + 1 + 1 + + + 2 + GB + 2 + 32 + + + 5.2.7 + 0 + IMAGE + 1c59a521885c465004456f74d003726c + test3 + + + 5.2.5 + 1 + IMAGE + C4D2CBE51669796E48623E006782F7DC + test2 + + + 5.2.4 + 2 + IMAGE + 4987E1E743FD641C879E1D3C5D50BCE0 + test1 + + + APPID + + + IPS-IDS + + + URLF + + + Anti-Virus + + + FortiGate-VM00 + FALSE + + + + FortiGate-VM01 + FW + + FORTINET + FortiGate-VM01 + VM01 + + + 1 + 1 + 1 + + + 2 + GB + 1 + 2 + + + 2 + GB + 2 + 32 + + + 5.2.7 + 0 + IMAGE + 1c59a521885c465004456f74d003726c + software file name 3 + + + 5.2.5 + 1 + IMAGE + C4D2CBE51669796E48623E006782F7DC + software file name 2 + + + 5.2.4 + 2 + IMAGE + 4987E1E743FD641C879E1D3C5D50BCE0 + software file name + + + APPID + + + IPS-IDS + + + URLF + + + Anti-Virus + + + license group + FALSE + + + + diff --git a/version.properties b/version.properties index a80dc76..b0a402c 100644 --- a/version.properties +++ b/version.properties @@ -1,33 +1,33 @@ -### +### # ============LICENSE_START======================================================= # MODEL LOADER SERVICE # ================================================================================ # Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. # ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and # limitations under the License. -# ============LICENSE_END========================================================= -### - -# Versioning variables -# Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... ) -# because they are used in Jenkins, whose plug-in doesn't support - -major=1 -minor=1 -patch=0 - -base_version=${major}.${minor}.${patch} - -# Release must be completed with git revision # in Jenkins -release_version=${base_version} -snapshot_version=${base_version}-SNAPSHOT +# ============LICENSE_END========================================================= +### + +# Versioning variables +# Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... ) +# because they are used in Jenkins, whose plug-in doesn't support + +major=1 +minor=1 +patch=0 + +base_version=${major}.${minor}.${patch} + +# Release must be completed with git revision # in Jenkins +release_version=${base_version} +snapshot_version=${base_version}-SNAPSHOT -- 2.16.6