From f5f13c4f6b6fe3b4d98e349dfd7db59339803436 Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Sun, 19 Feb 2017 12:35:04 +0200 Subject: push addional code Change-Id: Ia427bb3460cda3a896f8faced2de69eaf3807b74 Signed-off-by: Michael Lando --- .../action-library-rest-services/pom.xml | 130 +++ .../openecomp/sdcrests/action/rest/Actions.java | 206 ++++ .../rest/mapping/MapActionToActionResponseDto.java | 42 + .../sdcrests/action/rest/services/ActionsImpl.java | 1212 ++++++++++++++++++++ .../action-library-rest-types/pom.xml | 37 + .../sdcrests/action/types/ActionResponseDto.java | 149 +++ .../sdcrests/action/types/ActionVersionDto.java | 38 + .../sdcrests/action/types/ListResponseWrapper.java | 70 ++ .../action-library-rest/pom.xml | 22 + .../application-config-rest-services/pom.xml | 62 + .../rest/ApplicationConfiguration.java | 69 ++ ...licationConfigEntityToApplicationConfigDto.java | 34 + ...MapConfigurationDataToConfigurationDataDto.java | 34 + .../services/ApplicationConfigurationImpl.java | 87 ++ .../application-config-rest-types/pom.xml | 17 + .../types/ApplicationConfigDto.java | 43 + .../types/ConfigurationDataDto.java | 50 + .../application-config-rest/pom.xml | 23 + .../onboarding-rest-war/pom.xml | 183 +++ .../server/filters/ActionAuthenticationFilter.java | 115 ++ .../server/filters/ActionAuthorizationFilter.java | 71 ++ .../server/filters/ActionLibraryPrivilege.java | 59 + .../server/interceptors/DefaultOutput.java | 182 +++ .../interceptors/EmptyOutputOutInterceptor.java | 63 + .../server/interceptors/InternalEmptyObject.java | 34 + .../listeners/OnboardingAppStartupListener.java | 43 + .../src/main/resources/keyfile.txt | 27 + .../src/main/webapp/WEB-INF/beans-services.xml | 70 ++ .../src/main/webapp/WEB-INF/jetty-web.xml | 8 + .../src/main/webapp/WEB-INF/web.xml | 95 ++ .../onboarding-rest-war/templates/markdown.hbs | 105 ++ .../onboarding-rest-war/templates/operation.hbs | 73 ++ .../onboarding-rest-war/templates/security.hbs | 88 ++ .../templates/strapdown.html.hbs | 11 + .../openecomp-sdc-common-rest/pom.xml | 47 + .../openecomp/sdcrests/common/RestConstants.java | 29 + .../sdcrests/common/mapping/MapErrorCodeToDto.java | 34 + .../common/mapping/MapErrorMessageToDto.java | 33 + .../sdcrests/common/types/ErrorCodeDto.java | 53 + .../sdcrests/common/types/ErrorMessageDto.java | 44 + .../sdcrests/errors/DefaultExceptionMapper.java | 163 +++ .../openecomp/sdcrests/mapping/MappingBase.java | 104 ++ .../versioning/types/VersioningAction.java | 28 + .../wrappers/GenericCollectionWrapper.java | 107 ++ .../sdcrests/wrappers/StringWrapperResponse.java | 42 + .../errorCodesToResponseStatusMapping.json | 9 + openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml | 29 + .../sequence-rest/pom.xml | 15 + .../openecomp/sdcrests/service/rest/Service.java | 24 + .../service/rest/services/ServiceImpl.java | 26 + .../validation-rest/pom.xml | 23 + .../validation-rest-services/pom.xml | 144 +++ .../sdcrests/validation/rest/Validation.java | 52 + ...ionFileResponseToValidationFileResponseDto.java | 34 + .../validation/rest/services/ValidationImpl.java | 63 + .../validation-rest/validation-rest-types/pom.xml | 32 + .../types/ValidationFileResponseDto.java | 36 + .../vendor-license-rest/pom.xml | 24 + .../vendor-license-rest-services/pom.xml | 133 +++ .../vendorlicense/rest/EntitlementPools.java | 105 ++ .../sdcrests/vendorlicense/rest/FeatureGroups.java | 108 ++ .../vendorlicense/rest/LicenseAgreements.java | 109 ++ .../vendorlicense/rest/LicenseKeyGroups.java | 104 ++ .../vendorlicense/rest/VendorLicenseModels.java | 111 ++ .../MapChoiceOrOtherDtoToChoiceOrOther.java | 36 + .../MapChoiceOrOtherToChoiceOrOtherDto.java | 35 + ...lementPoolEntityToEntitlementPoolEntityDto.java | 53 + ...ementPoolRequestDtoToEntitlementPoolEntity.java | 51 + ...tureGroupDescriptorDtoToFeatureGroupEntity.java | 36 + ...tureGroupEntityToFeatureGroupDescriptorDto.java | 35 + ...ementDescriptorDtoToLicenseAgreementEntity.java | 38 + ...ementEntityToLicenseAgreementDescriptorDto.java | 38 + ...seKeyGroupEntityToLicenseKeyGroupEntityDto.java | 40 + ...eKeyGroupRequestDtoToLicenseKeyGroupEntity.java | 38 + ...pMultiChoiceOrOtherDtoToMultiChoiceOrOther.java | 36 + ...pMultiChoiceOrOtherToMultiChoiceOrOtherDto.java | 35 + ...eModelRequestDtoToVendorLicenseModelEntity.java | 36 + ...rLicenseModelToVendorLicenseModelEntityDto.java | 60 + .../rest/services/EntitlementPoolsImpl.java | 157 +++ .../rest/services/FeatureGroupsImpl.java | 169 +++ .../rest/services/LicenseAgreementsImpl.java | 186 +++ .../rest/services/LicenseKeyGroupsImpl.java | 159 +++ .../rest/services/VendorLicenseModelsImpl.java | 135 +++ .../vendor-license-rest-types/pom.xml | 30 + .../vendorlicense/types/ChoiceOrOtherDto.java | 75 ++ .../types/EntitlementPoolEntityDto.java | 48 + .../types/EntitlementPoolRequestDto.java | 144 +++ .../types/FeatureGroupDescriptorDto.java | 59 + .../vendorlicense/types/FeatureGroupEntityDto.java | 69 ++ .../vendorlicense/types/FeatureGroupModelDto.java | 66 ++ .../types/FeatureGroupRequestDto.java | 48 + .../types/FeatureGroupUpdateRequestDto.java | 48 + .../types/LicenseAgreementDescriptorDto.java | 74 ++ .../types/LicenseAgreementEntityDto.java | 51 + .../types/LicenseAgreementModelDto.java | 47 + .../types/LicenseAgreementRequestDto.java | 39 + .../types/LicenseAgreementUpdateRequestDto.java | 38 + .../types/LicenseKeyGroupEntityDto.java | 45 + .../types/LicenseKeyGroupRequestDto.java | 74 ++ .../vendorlicense/types/MultiChoiceOrOtherDto.java | 79 ++ .../types/VendorLicenseModelActionRequestDto.java | 36 + .../types/VendorLicenseModelEntityDto.java | 85 ++ .../types/VendorLicenseModelRequestDto.java | 62 + .../validation/ChoiceOrOtherSequenceProvider.java | 45 + .../MultiChoiceOrOtherSequenceProvider.java | 47 + .../types/validation/OtherChoiceValidation.java | 24 + .../vendor-software-products-rest/pom.xml | 23 + .../vendor-software-products-rest-services/pom.xml | 144 +++ .../sdcrests/vsp/rest/ComponentProcesses.java | 168 +++ .../sdcrests/vsp/rest/ComponentUploads.java | 104 ++ .../openecomp/sdcrests/vsp/rest/Components.java | 142 +++ .../org/openecomp/sdcrests/vsp/rest/Networks.java | 107 ++ .../java/org/openecomp/sdcrests/vsp/rest/Nics.java | 144 +++ .../org/openecomp/sdcrests/vsp/rest/Processes.java | 151 +++ .../sdcrests/vsp/rest/VendorSoftwareProducts.java | 193 ++++ .../mapping/MapComponentDataToComponentDto.java | 35 + .../mapping/MapComponentEntityToComponentDto.java | 37 + .../MapComponentRequestDtoToComponentEntity.java | 38 + .../mapping/MapCompositionEntityResponseToDto.java | 47 + .../MapCompositionEntityValidationDataToDto.java | 44 + .../vsp/rest/mapping/MapMibUploadStatusToDto.java | 33 + .../rest/mapping/MapNetworkEntityToNetworkDto.java | 37 + .../MapNetworkRequestDtoToNetworkEntity.java | 37 + .../vsp/rest/mapping/MapNetworkToNetworkDto.java | 33 + .../vsp/rest/mapping/MapNicEntityToNicDto.java | 37 + .../rest/mapping/MapNicRequestDtoToNicEntity.java | 37 + .../sdcrests/vsp/rest/mapping/MapNicToNicDto.java | 35 + .../mapping/MapPackageInfoToPackageInfoDto.java | 42 + .../MapProcessEntityToProcessEntityDto.java | 36 + .../MapProcessRequestDtoToProcessEntity.java | 34 + ...ionnaireResponseToQuestionnaireResponseDto.java | 35 + ...pUploadFileResponseToUploadFileResponseDto.java | 36 + .../rest/mapping/MapValidationResponseToDto.java | 90 ++ ...edVendorSoftwareProductInfoToVspDetailsDto.java | 74 ++ .../mapping/MapVspDescriptionDtoToVspDetails.java | 56 + .../mapping/MspVspDetailsToVspCreationDto.java | 32 + .../vsp/rest/services/ComponentProcessesImpl.java | 144 +++ .../vsp/rest/services/ComponentUploadsImpl.java | 87 ++ .../sdcrests/vsp/rest/services/ComponentsImpl.java | 145 +++ .../sdcrests/vsp/rest/services/NetworksImpl.java | 115 ++ .../sdcrests/vsp/rest/services/NicsImpl.java | 140 +++ .../sdcrests/vsp/rest/services/ProcessesImpl.java | 89 ++ .../rest/services/VendorSoftwareProductsImpl.java | 228 ++++ .../vendor-software-products-rest-types/pom.xml | 32 + .../vendorsoftwareproducts/types/ComponentDto.java | 35 + .../types/ComponentRequestDto.java | 53 + .../types/CompositionDataEntityDto.java | 24 + .../types/CompositionEntityResponseDto.java | 51 + .../types/CompositionEntityValidationDataDto.java | 65 ++ .../types/MibUploadStatusDto.java | 46 + .../vendorsoftwareproducts/types/NetworkDto.java | 34 + .../types/NetworkRequestDto.java | 47 + .../vendorsoftwareproducts/types/NicDto.java | 43 + .../types/NicRequestDto.java | 52 + .../types/PackageInfoDto.java | 124 ++ .../types/ProcessEntityDto.java | 42 + .../types/ProcessRequestDto.java | 47 + .../types/QuestionnaireResponseDto.java | 42 + .../types/QuestionnaireValidationResultDto.java | 42 + .../types/TranslatedFileDataDto.java | 97 ++ .../types/UploadFileResponseDto.java | 63 + .../types/ValidationResponseDto.java | 77 ++ .../types/VendorSoftwareProductAction.java | 29 + .../VersionSoftwareProductActionRequestDto.java | 33 + .../types/VspCreationDto.java | 33 + .../types/VspDescriptionDto.java | 115 ++ .../types/VspDetailsDto.java | 97 ++ .../types/validation/CustomJsonValidator.java | 40 + .../types/validation/IsValidJson.java | 77 ++ 169 files changed, 12572 insertions(+) create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/Actions.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/mapping/MapActionToActionResponseDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ActionResponseDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ActionVersionDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ListResponseWrapper.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapApplicationConfigEntityToApplicationConfigDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapConfigurationDataToConfigurationDataDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ApplicationConfigDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ConfigurationDataDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionLibraryPrivilege.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/DefaultOutput.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/EmptyOutputOutInterceptor.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/InternalEmptyObject.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/resources/keyfile.txt create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/jetty-web.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/templates/markdown.hbs create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/templates/operation.hbs create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/templates/security.hbs create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/templates/strapdown.html.hbs create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorCodeToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorMessageToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorCodeDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorMessageDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/versioning/types/VersioningAction.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/StringWrapperResponse.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/resources/errorCodesToResponseStatusMapping.json create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/src/main/java/org/openecomp/sdcrests/service/rest/Service.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/src/main/java/org/openecomp/sdcrests/service/rest/services/ServiceImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/Validation.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/mapping/MapValidationFileResponseToValidationFileResponseDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/services/ValidationImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/src/main/java/org/openecomp/sdcrests/validation/types/ValidationFileResponseDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPools.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/FeatureGroups.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseAgreements.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroups.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/VendorLicenseModels.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherDtoToChoiceOrOther.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherToChoiceOrOtherDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementEntityToLicenseAgreementDescriptorDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherDtoToMultiChoiceOrOther.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherToMultiChoiceOrOtherDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/ChoiceOrOtherDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolEntityDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupDescriptorDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupEntityDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupModelDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupUpdateRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementDescriptorDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementEntityDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementModelDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementUpdateRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupEntityDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/MultiChoiceOrOtherDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelActionRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelEntityDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/ChoiceOrOtherSequenceProvider.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/MultiChoiceOrOtherSequenceProvider.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/OtherChoiceValidation.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentProcesses.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentUploads.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Components.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Networks.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Nics.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Processes.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDataToComponentDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentRequestDtoToComponentEntity.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityResponseToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityValidationDataToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapMibUploadStatusToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkEntityToNetworkDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkRequestDtoToNetworkEntity.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkToNetworkDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicEntityToNicDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicRequestDtoToNicEntity.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicToNicDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapPackageInfoToPackageInfoDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessEntityToProcessEntityDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessRequestDtoToProcessEntity.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireResponseToQuestionnaireResponseDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapUploadFileResponseToUploadFileResponseDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapValidationResponseToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MspVspDetailsToVspCreationDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentUploadsImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentsImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NetworksImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NicsImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ProcessesImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionDataEntityDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionEntityResponseDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionEntityValidationDataDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/MibUploadStatusDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NetworkDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NetworkRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/PackageInfoDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ProcessEntityDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ProcessRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireResponseDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireValidationResultDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/TranslatedFileDataDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/UploadFileResponseDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ValidationResponseDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VendorSoftwareProductAction.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VersionSoftwareProductActionRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDetailsDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/CustomJsonValidator.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/IsValidJson.java (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp') diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml new file mode 100644 index 0000000000..23ba4e8c64 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml @@ -0,0 +1,130 @@ + + + 4.0.0 + + + org.openecomp.sdc.onboarding + action-library-rest + 1.0.0-SNAPSHOT + + + action-library-rest-services + + + + + ${project.build.directory}/generated-sources/error-codes + + + + + ${project.groupId} + action-library-rest-types + ${project.version} + + + + + org.springframework + spring-core + ${spring.framework.version} + + + org.springframework + spring-context + ${spring.framework.version} + + + org.springframework + spring-context-support + ${spring.framework.version} + + + org.springframework + spring-web + ${spring.framework.version} + + + org.springframework + spring-beans + ${spring.framework.version} + + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + ${cxf.version} + + + + org.apache.httpcomponents + httpclient + ${http.client.version} + + + org.apache.httpcomponents + httpcore + ${http.client.version} + + + + javax.ws.rs + javax.ws.rs-api + ${ws.rs.version} + + + + + cglib + cglib-nodep + ${cglib.nodep.version} + runtime + + + + + javax.inject + javax.inject + ${javax.inject.version} + provided + + + org.openecomp.sdc + openecomp-sdc-action-manager + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-action-api + ${project.version} + + + org.openecomp.sdc.sdc_common + openecomp-logging-api + ${project.version} + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + test/core/unittest/offline/** + + true + + + + + + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/Actions.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/Actions.java new file mode 100644 index 0000000000..c7e3bbddec --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/Actions.java @@ -0,0 +1,206 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.action.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import org.openecomp.sdcrests.action.types.ActionResponseDto; +import org.springframework.validation.annotation.Validated; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +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.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +/** + * Defines various CRUD API that can be performed on Action. + */ +@Path("/workflow/v1.0/actions") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Actions") +@Validated +public interface Actions { + + /** + * List All Major, Last Minor and Candidate version if any for Given Action Invariant UUID + * + * @return List of All Major, Last Minor and Candidate version if any Of Action with given + actionInvariantUuId. If actionUUID is provided then only action with given actionInvariantUuId + and actionUUID + */ + @GET + @Path("/{actionInvariantUUID}") + @ApiOperation(value = "List Actions For Given Action Invariant UUID", responseContainer = "List") + Response getActionsByActionInvariantUuId( + @PathParam("actionInvariantUUID") String actionInvariantUuId, + @QueryParam("version") String actionUuId, @Context HttpServletRequest servletRequest); + + /** + * Get list of actions based on a filter criteria. If no filter is sent all actions will + be returned + * + * @return List Of Last Major and Last Minor of All Actions based on filter criteria + */ + @GET + @ApiOperation(value = "List Filtered Actions ", + notes = "Get list of actions based on a filter criteria | If no filter is sent all actions " + + "will be returned", + responseContainer = "List") + Response getFilteredActions(@QueryParam("vendor") String vendor, + @QueryParam("category") String category, + @QueryParam("name") String name, + @QueryParam("modelId") String modelId, + @QueryParam("componentId") String componentId, + @Context HttpServletRequest servletRequest); + + /** + * List ECOMP Components supported by Action Library. + * + * @return List of ECOMP Components supported by Action Library. + */ + @GET + @Path("/components") + @ApiOperation(value = "List ECOMP Components supported by Action Library", + responseContainer = "List") + Response getEcompComponents(@Context HttpServletRequest servletRequest); + + /** + * Create a new Action based on request JSON. + * + * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action. + */ + @POST + @ApiOperation(value = "Create a new Action") + Response createAction(String requestJson, @Context HttpServletRequest servletRequest); + + /** + * Update an existing action with parameters provided in requestJson. + * + * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action. + */ + @PUT + @Path("/{actionInvariantUUID}") + @ApiOperation(value = "Update an existing action") + Response updateAction(@PathParam("actionInvariantUUID") String actionInvariantUuId, + String requestJson, @Context HttpServletRequest servletRequest); + + /** + * Delete an action. + * + * @param actionInvariantUuId Invariant UUID of the action to be deleted. + * @param servletRequest Servlet request object. + * @return Empty response object. + */ + @DELETE + @Path("/{actionInvariantUUID}") + @ApiOperation(value = "Delete Action") + Response deleteAction(@PathParam("actionInvariantUUID") String actionInvariantUuId, + @Context HttpServletRequest servletRequest); + + /** + * Performs Checkout/Undo_Checkout/Checkin/Submit Operation on Action. + * + * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action. + */ + @POST + @Path("/{actionInvariantUUID}") + @ApiOperation(value = "Actions on a action", + notes = "Performs one of the following actions on a action: |" + + "Checkout: Locks it for edits by other users. Only the locking user sees the edited " + + "version.|" + + "Undo_Checkout: Unlocks it and deletes the edits that were done.|" + + "Checkin: Unlocks it and activates the edited version to all users.| " + + "Submit: Finalize its active version.|") + Response actOnAction(@PathParam("actionInvariantUUID") String actionInvariantUuId, + String requestJson, @Context HttpServletRequest servletRequest); + + /** + * Upload an artifact to an action. + * + * @param actionInvariantUuId Invariant UUID of the action to which the artifact is uploaded. + * @param artifactName Name of the artifact. + * @param artifactLabel Label of the artifact. + * @param artifactCategory Category of the artifact. + * @param artifactDescription Description of the artifact. + * @param artifactProtection Artifact protection mode. + * @param checksum Checksum of the artifact. + * @param artifactToUpload Artifact content object. + * @param servletRequest Servlet request object. + * @return Generated UUID of the uploaded artifact. + */ + @POST + @Path("/{actionInvariantUUID}/artifacts") + @ApiOperation(value = "Upload new Artifact") + @Consumes(MediaType.MULTIPART_FORM_DATA) + Response uploadArtifact(@PathParam("actionInvariantUUID") String actionInvariantUuId, + @Multipart(value = "artifactName", required = false) String artifactName, + @Multipart(value = "artifactLabel", required = false) String artifactLabel, + @Multipart(value = "artifactCategory", required = false) String artifactCategory, + @Multipart(value = "artifactDescription", required = false) String artifactDescription, + @Multipart(value = "artifactProtection", required = false) String artifactProtection, + @HeaderParam("Content-MD5") String checksum, + @Multipart(value = "uploadArtifact", required = false) Attachment artifactToUpload, + @Context HttpServletRequest servletRequest); + + @GET + @Path("/{actionUUID}/artifacts/{artifactUUID}") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @ApiOperation(value = "Downloads artifact for action") + Response downloadArtifact(@PathParam("actionUUID") String actionUuId, + @PathParam("artifactUUID") String artifactUuId, + @Context HttpServletRequest servletRequest); + + @DELETE + @Path("/{actionInvariantUUID}/artifacts/{artifactUUID}") + @ApiOperation(value = "Delete Artifact") + Response deleteArtifact(@PathParam("actionInvariantUUID") String actionInvariantUuId, + @PathParam("artifactUUID") String artifactUuId, + @Context HttpServletRequest servletRequest); + + @PUT + @Path("/{actionInvariantUUID}/artifacts/{artifactUUID}") + @ApiOperation(value = "Update an existing artifact") + @Consumes(MediaType.MULTIPART_FORM_DATA) + Response updateArtifact(@PathParam("actionInvariantUUID") String actionInvariantUuId, + @PathParam("artifactUUID") String artifactUuId, + @Multipart(value = "artifactName", required = false) String artifactName, + @Multipart(value = "artifactLabel", required = false) String artifactLabel, + @Multipart(value = "artifactCategory", required = false) String artifactCategory, + @Multipart(value = "artifactDescription", required = false) String artifactDescription, + @Multipart(value = "artifactProtection", required = false) String artifactProtection, + @HeaderParam("Content-MD5") String checksum, + @Multipart(value = "updateArtifact", required = false) Attachment artifactToUpdate, + @Context HttpServletRequest servletRequest); + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/mapping/MapActionToActionResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/mapping/MapActionToActionResponseDto.java new file mode 100644 index 0000000000..27d3f482c7 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/mapping/MapActionToActionResponseDto.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.action.rest.mapping; + +import org.openecomp.sdc.action.types.Action; +import org.openecomp.sdcrests.action.types.ActionResponseDto; +import org.openecomp.sdcrests.mapping.MappingBase; + + +/** + * Maps Source Action Object To Action Response DTO. + */ +public class MapActionToActionResponseDto extends MappingBase { + + @Override + public void doMapping(Action source, ActionResponseDto target) { + target.setActionUuId(source.getActionUuId()); + target.setActionInvariantUuId(source.getActionInvariantUuId()); + target.setVersion(source.getVersion()); + if (source.getStatus() != null) { + target.setStatus(source.getStatus().name()); + } + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java new file mode 100644 index 0000000000..7e9cca0e0b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java @@ -0,0 +1,1212 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.action.rest.services; + +import static org.openecomp.sdc.action.ActionConstants.ACTION_REQUEST_PARAM_END_POINT_URI; +import static org.openecomp.sdc.action.ActionConstants.ACTION_REQUEST_PARAM_NAME; +import static org.openecomp.sdc.action.ActionConstants.ACTION_REQUEST_PARAM_SUPPORTED_COMPONENTS; +import static org.openecomp.sdc.action.ActionConstants.ACTION_REQUEST_PARAM_SUPPORTED_MODELS; +import static org.openecomp.sdc.action.ActionConstants.ARTIFACT_FILE; +import static org.openecomp.sdc.action.ActionConstants.ARTIFACT_NAME; +import static org.openecomp.sdc.action.ActionConstants.BE_FQDN; +import static org.openecomp.sdc.action.ActionConstants.CATEGORY_LOG_LEVEL; +import static org.openecomp.sdc.action.ActionConstants.CLIENT_IP; +import static org.openecomp.sdc.action.ActionConstants.ERROR_DESCRIPTION; +import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_CATEGORY; +import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_ECOMP_COMPONENT; +import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_MODEL; +import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NAME; +import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NONE; +import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_VENDOR; +import static org.openecomp.sdc.action.ActionConstants.INSTANCE_UUID; +import static org.openecomp.sdc.action.ActionConstants.LOCAL_ADDR; +import static org.openecomp.sdc.action.ActionConstants.MAX_ACTION_ARTIFACT_SIZE; +import static org.openecomp.sdc.action.ActionConstants.MDC_ASDC_INSTANCE_UUID; +import static org.openecomp.sdc.action.ActionConstants.PARTNER_NAME; +import static org.openecomp.sdc.action.ActionConstants.REMOTE_HOST; +import static org.openecomp.sdc.action.ActionConstants.REQUEST_EMPTY_BODY; +import static org.openecomp.sdc.action.ActionConstants.REQUEST_ID; +import static org.openecomp.sdc.action.ActionConstants.REQUEST_TYPE_CREATE_ACTION; +import static org.openecomp.sdc.action.ActionConstants.REQUEST_TYPE_UPDATE_ACTION; +import static org.openecomp.sdc.action.ActionConstants.REQUEST_TYPE_VERSION_ACTION; +import static org.openecomp.sdc.action.ActionConstants.SERVICE_INSTANCE_ID; +import static org.openecomp.sdc.action.ActionConstants.SERVICE_METRIC_BEGIN_TIMESTAMP; +import static org.openecomp.sdc.action.ActionConstants.SERVICE_NAME; +import static org.openecomp.sdc.action.ActionConstants.STATUS; +import static org.openecomp.sdc.action.ActionConstants.STATUS_CODE; +import static org.openecomp.sdc.action.ActionConstants.SUPPORTED_COMPONENTS_ID; +import static org.openecomp.sdc.action.ActionConstants.SUPPORTED_MODELS_VERSION_ID; +import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY; +import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY_API; +import static org.openecomp.sdc.action.ActionConstants.TARGET_SERVICE_NAME; +import static org.openecomp.sdc.action.ActionConstants.TIMESTAMP; +import static org.openecomp.sdc.action.ActionConstants.UPDATED_BY; +import static org.openecomp.sdc.action.ActionConstants.X_ECOMP_INSTANCE_ID_HEADER_PARAM; +import static org.openecomp.sdc.action.ActionConstants.X_ECOMP_REQUEST_ID_HEADER_PARAM; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_CHECKSUM_ERROR_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_NAME; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_NAME_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_PROTECTION_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_READ_FILE_ERROR; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_TOO_BIG_ERROR; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_TOO_BIG_ERROR_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_FILTER_MULTIPLE_QUERY_PARAM_NOT_SUPPORTED; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_INSTANCE_ID_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_PARAM_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_REQUEST_BODY_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_REQUEST_ID_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_SEARCH_CRITERIA; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_MULT_SEARCH_CRITERIA; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_ARTIFACT_CHECKSUM_ERROR; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_ARTIFACT_INVALID_PROTECTION_VALUE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_ARTIFACT_OPERATION_ALLOWED; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_BODY_EMPTY; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_CONTENT_TYPE_INVALID; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_ECOMP_INSTANCE_ID_INVALID; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_ECOMP_REQUEST_ID_INVALID; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_FILTER_PARAM_INVALID; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_INVALID_GENERIC_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_INVALID_NAME; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_MISSING_MANDATORY_PARAM; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UNSUPPORTED_OPERATION; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_CODE; +import static org.openecomp.sdc.action.util.ActionUtil.actionErrorLogProcessor; +import static org.openecomp.sdc.action.util.ActionUtil.actionLogPostProcessor; + +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.openecomp.core.logging.api.Logger; +import org.openecomp.core.logging.api.LoggerFactory; +import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.action.ActionConstants; +import org.openecomp.sdc.action.ActionManager; +import org.openecomp.sdc.action.errors.ActionErrorConstants; +import org.openecomp.sdc.action.errors.ActionException; +import org.openecomp.sdc.action.logging.CategoryLogLevel; +import org.openecomp.sdc.action.logging.StatusCode; +import org.openecomp.sdc.action.types.Action; +import org.openecomp.sdc.action.types.ActionArtifact; +import org.openecomp.sdc.action.types.ActionArtifactProtection; +import org.openecomp.sdc.action.types.ActionRequest; +import org.openecomp.sdc.action.types.EcompComponent; +import org.openecomp.sdcrests.action.rest.Actions; +import org.openecomp.sdcrests.action.rest.mapping.MapActionToActionResponseDto; +import org.openecomp.sdcrests.action.types.ActionResponseDto; +import org.openecomp.sdcrests.action.types.ActionVersionDto; +import org.openecomp.sdcrests.action.types.ListResponseWrapper; +import org.openecomp.sdcrests.wrappers.StringWrapperResponse; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.TimeZone; +import javax.inject.Named; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Response; + + + +/** + * Implements various CRUD API that can be performed on Action. + */ +@SuppressWarnings("ALL") +@Named +@Service("actions") +@Scope(value = "prototype") +@Validated +public class ActionsImpl implements Actions { + + @Autowired + private ActionManager actionManager; + private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName()); + + private String whitespaceCharacters = "\\s" /* dummy empty string for homogeneity */ + + "\\u0009" // CHARACTER TABULATION + + "\\u000A" // LINE FEED (LF) + + "\\u000B" // LINE TABULATION + + "\\u000C" // FORM FEED (FF) + + "\\u000D" // CARRIAGE RETURN (CR) + + "\\u0020" // SPACE + + "\\u0085" // NEXT LINE (NEL) + + "\\u00A0" // NO-BREAK SPACE + + "\\u1680" // OGHAM SPACE MARK + + "\\u180E" // MONGOLIAN VOWEL SEPARATOR + + "\\u2000" // EN QUAD + + "\\u2001" // EM QUAD + + "\\u2002" // EN SPACE + + "\\u2003" // EM SPACE + + "\\u2004" // THREE-PER-EM SPACE + + "\\u2005" // FOUR-PER-EM SPACE + + "\\u2006" // SIX-PER-EM SPACE + + "\\u2007" // FIGURE SPACE + + "\\u2008" // PUNCTUATION SPACE + + "\\u2009" // THIN SPACE + + "\\u200A" // HAIR SPACE + + "\\u2028" // LINE SEPARATOR + + "\\u2029" // PARAGRAPH SEPARATOR + + "\\u202F" // NARROW NO-BREAK SPACE + + "\\u205F" // MEDIUM MATHEMATICAL SPACE + + "\\u3000" // IDEOGRAPHIC SPACE + ; + private String invalidFilenameChars = "#<>$+%!`&*'|{}?\"=/:@\\\\"; + private String whitespaceRegex = ".*[" + whitespaceCharacters + "].*"; + private String invalidFilenameRegex = ".*[" + whitespaceCharacters + invalidFilenameChars + "].*"; + + /** + * Calculate the checksum for a given input. + * + * @param input Byte array for which the checksum has to be calculated. + * @return Calculated checksum of the input byte array. + */ + private static String calculateCheckSum(byte[] input) { + String checksum = null; + if (input != null) { + checksum = DigestUtils.md5Hex(input); + } + return checksum; + } + + /** + * Convert timestamp to UTC format date string. + * + * @param timeStamp UTC timestamp to be converted to the UTC Date format. + * @return UTC formatted Date string from timestamp. + */ + public static String getUTCDateStringFromTimestamp(Date timeStamp) { + DateFormat df = new SimpleDateFormat("dd MMM yyyy kk:mm:ss z"); + df.setTimeZone(TimeZone.getTimeZone("GMT")); + return df.format(timeStamp); + } + /** + * Initialize MDC for logging the current request + * @param actionInvariantId Action Invariant Id if available (null otherwise) + * @param servletRequest Request Contecxt object + * @param requestType Current action request (CRUD of Action, Artifact, Version operations) + */ + private void initializeRequestMDC(HttpServletRequest servletRequest, String actionInvariantId, ActionRequest requestType){ + MDC.put(REQUEST_ID, servletRequest.getHeader(X_ECOMP_REQUEST_ID_HEADER_PARAM)); + MDC.put(PARTNER_NAME, servletRequest.getRemoteUser()); + MDC.put(INSTANCE_UUID, MDC_ASDC_INSTANCE_UUID); + MDC.put(SERVICE_METRIC_BEGIN_TIMESTAMP, String.valueOf(System.currentTimeMillis())); + MDC.put(STATUS_CODE, StatusCode.COMPLETE.name()); + MDC.put(SERVICE_NAME, requestType.name()); + MDC.put(CLIENT_IP, MDC.get(REMOTE_HOST)); + MDC.put(SERVICE_INSTANCE_ID, actionInvariantId); + MDC.put(LOCAL_ADDR, MDC.get("ServerIPAddress")); + MDC.put(BE_FQDN, MDC.get("ServerFQDN")); + + if(log.isDebugEnabled()) + MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.DEBUG.name()); + else if(log.isInfoEnabled()) + MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.INFO.name()); + else if(log.isWarnEnabled()) + MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.WARN.name()); + else if(log.isErrorEnabled()) + MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.ERROR.name()); + } + + @Override + public Response getActionsByActionInvariantUuId(String invariantId, String actionUuId, + HttpServletRequest servletRequest) { + ListResponseWrapper responseList = new ListResponseWrapper(); + + try{ + log.debug(" entering getActionsByActionInvariantUUID "); + initializeRequestMDC(servletRequest, invariantId, ActionRequest.GET_ACTIONS_INVARIANT_ID); + MDC.put(SERVICE_INSTANCE_ID, invariantId); + + if(StringUtils.isEmpty(servletRequest.getQueryString())){ + responseList = getActionsByInvId(servletRequest,invariantId); + } else{ + Response response = getActionByUUID(servletRequest, invariantId, actionUuId); + actionLogPostProcessor(StatusCode.COMPLETE, true); + return response; + } + } catch (ActionException e){ + actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + log.error(""); + throw e; + } catch (Exception e){ + actionLogPostProcessor(StatusCode.ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(""); + throw e; + } finally { + finalAuditMetricsLogProcessor(ActionRequest.GET_ACTIONS_INVARIANT_ID.name()); + } + + log.debug(" exit getActionsByActionInvariantUUID " ); + actionLogPostProcessor(StatusCode.COMPLETE, true); + return Response.ok(responseList).build(); + } + + private ListResponseWrapper getActionsByInvId(HttpServletRequest servletRequest, String invariantId){ + log.debug(" entering getActionsByInvId with invariantId= " + invariantId ); + ListResponseWrapper responseList = new ListResponseWrapper(); + if(StringUtils.isEmpty(servletRequest.getQueryString())){ + Map errorMap = validateRequestHeaders(servletRequest); + Map queryParamErrors = validateQueryParam(invariantId); + errorMap.putAll(queryParamErrors); + if(errorMap.isEmpty()) { + List actions = actionManager.getActionsByActionInvariantUuId(invariantId); + List versionList = new ArrayList(); + for (Action action : actions) { + ActionResponseDto responseDTO = createResponseDTO(action); + versionList.add(responseDTO); + } + responseList .setVersions(versionList); + responseList.setActionList(null); + + } else{ + checkAndThrowError(errorMap); + } + } + log.debug(" exit getActionsByInvId with invariantId= " + invariantId ); + return responseList; + } + + private Response getActionByUUID(HttpServletRequest servletRequest, String invariantID, String actionUUID) throws ActionException{ + int noOfFilterParams = 0; + Response response = null; + log.debug(" entering getActionByUUID with invariantID= " + invariantID + " and actionUUID= " + actionUUID); + if(!StringUtils.isEmpty(actionUUID)) { + noOfFilterParams ++; + response = getActionsByUniqueID(actionUUID, servletRequest, invariantID); + } + if(noOfFilterParams == 0) + throw new ActionException(ACTION_INVALID_SEARCH_CRITERIA, ACTION_REQUEST_FILTER_PARAM_INVALID); + + log.debug(" exit getActionByUUID with invariantID= " + invariantID + " and actionUUID= " + actionUUID); + return response; + } + + private void finalAuditMetricsLogProcessor(String targetServiceName) { + MDC.put(TARGET_SERVICE_NAME, targetServiceName); + MDC.put(TARGET_ENTITY, TARGET_ENTITY_API); + log.metrics(""); + log.audit(""); + } + + @Override + public Response getEcompComponents(HttpServletRequest servletRequest) { + try { + log.debug(" entering getECOMPComponents "); + initializeRequestMDC(servletRequest, "", ActionRequest.GET_ECOMP_COMPONENTS); + //Validate request syntax before passing to the manager + Map errorMap = validateRequestHeaders(servletRequest); + checkAndThrowError(errorMap); + ListResponseWrapper response = new ListResponseWrapper(); + List ecompComponents = actionManager.getEcompComponents(); + response.setActionList(null); + response.setComponentList(ecompComponents); + log.debug(" exit getECOMPComponents "); + actionLogPostProcessor(StatusCode.COMPLETE, true); + return Response.ok(response).build(); + }catch (ActionException e){ + actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + log.error(""); + throw e; + } + catch (Exception e){ + actionLogPostProcessor(StatusCode.ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(""); + throw e; + } + finally { + finalAuditMetricsLogProcessor(ActionRequest.GET_ECOMP_COMPONENTS.name()); + } + } + + @Override + public Response getFilteredActions(String vendor, String category, String name, String modelId, + String componentId, HttpServletRequest servletRequest) { + try { + log.debug(" entering getFilteredActions "); + int noOfFilterParams = 0; + Response response = null; + initializeRequestMDC(servletRequest, "", ActionRequest.GET_FILTERED_ACTIONS); + if (!StringUtils.isEmpty(vendor)) { + noOfFilterParams++; + } + if (!StringUtils.isEmpty(category)) { + noOfFilterParams++; + } + if (!StringUtils.isEmpty(name)) { + noOfFilterParams++; + } + if (!StringUtils.isEmpty(modelId)) { + noOfFilterParams++; + } + if (!StringUtils.isEmpty(componentId)) { + noOfFilterParams++; + } + if (StringUtils.isEmpty(servletRequest.getQueryString())) { + response = getAllActions(servletRequest); + log.debug(" exit getFilteredActions "); + actionLogPostProcessor(StatusCode.COMPLETE, true); + return response; + } + if (noOfFilterParams > 1) { + throw new ActionException(ACTION_MULT_SEARCH_CRITERIA, + ACTION_FILTER_MULTIPLE_QUERY_PARAM_NOT_SUPPORTED); + } + if (noOfFilterParams == 0) { + throw new ActionException(ACTION_INVALID_SEARCH_CRITERIA, + ACTION_REQUEST_FILTER_PARAM_INVALID); + } + ListResponseWrapper responseList = null; + if (!StringUtils.isEmpty(vendor)) { + response = getActionsByVendor(vendor, servletRequest); + } else if (!StringUtils.isEmpty(category)) { + response = getActionsByCategory(category, servletRequest); + } else if (!StringUtils.isEmpty(name)) { + response = getActionsByName(name, servletRequest); + } else if (!StringUtils.isEmpty(modelId)) { + response = getActionsByModel(modelId, servletRequest); + } else if (!StringUtils.isEmpty(componentId)) { + response = getActionsByECOMPComponent(componentId, servletRequest); + } else { + throw new ActionException(ACTION_INVALID_PARAM_CODE, ACTION_REQUEST_FILTER_PARAM_INVALID); + } + log.debug(" exit getFilteredActions "); + actionLogPostProcessor(StatusCode.COMPLETE, true); + return response; + } + catch (ActionException e){ + actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + log.error(""); + throw e; + } + catch (Exception e){ + actionLogPostProcessor(StatusCode.ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(""); + throw e; + } + finally { + finalAuditMetricsLogProcessor(ActionRequest.GET_FILTERED_ACTIONS.name()); + } + } + + @Override + public Response createAction(String requestJson, HttpServletRequest servletRequest) { + try { + initializeRequestMDC(servletRequest, null, ActionRequest.CREATE_ACTION); + log.debug(" entering API createAction "); + Map errorMap = validateRequestHeaders(servletRequest); + Map requestBodyErrors = + validateRequestBody(REQUEST_TYPE_CREATE_ACTION, requestJson); + errorMap.putAll(requestBodyErrors); + ActionResponseDto actionResponseDto = new ActionResponseDto(); + if (errorMap.isEmpty()) { + String user = servletRequest.getRemoteUser(); + Action action = JsonUtil.json2Object(requestJson, Action.class); + action.setData(requestJson); + Action responseAction = actionManager.createAction(action, user); + MDC.put(SERVICE_INSTANCE_ID, responseAction.getActionInvariantUuId()); + new MapActionToActionResponseDto().doMapping(responseAction, actionResponseDto); + } else { + checkAndThrowError(errorMap); + } + actionLogPostProcessor(StatusCode.COMPLETE, true); + log.debug(" exit API createAction with ActionInvariantUUID= " + MDC.get(SERVICE_INSTANCE_ID)); + return Response.ok(actionResponseDto).build(); + }catch (ActionException e){ + actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + log.error(""); + throw e; + }catch (Exception e){ + actionLogPostProcessor(StatusCode.ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(e.getMessage()); + throw e; + }finally { + finalAuditMetricsLogProcessor(ActionRequest.CREATE_ACTION.name()); + } + + } + + @Override + public Response updateAction(String actionInvariantUuId, String requestJson, + HttpServletRequest servletRequest) { + try { + initializeRequestMDC(servletRequest, actionInvariantUuId, ActionRequest.UPDATE_ACTION); + log.debug(" entering API updateAction "); + Map errorMap = validateRequestHeaders(servletRequest); + Map requestBodyErrors = + validateRequestBody(REQUEST_TYPE_UPDATE_ACTION, requestJson); + errorMap.putAll(requestBodyErrors); + ActionResponseDto actionResponseDto = new ActionResponseDto(); + if (errorMap.isEmpty()) { + String user = servletRequest.getRemoteUser(); + Action action = JsonUtil.json2Object(requestJson, Action.class); + action.setActionInvariantUuId(actionInvariantUuId); + action.setData(requestJson); + Action updatedAction = actionManager.updateAction(action, user); + new MapActionToActionResponseDto().doMapping(updatedAction, actionResponseDto); + } else { + checkAndThrowError(errorMap); + } + actionLogPostProcessor(StatusCode.COMPLETE, true); + log.debug(" exit API updateAction "); + return Response.ok(actionResponseDto).build(); + }catch (ActionException e){ + actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + log.error(""); + throw e; + }catch (Exception e){ + actionLogPostProcessor(StatusCode.ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(e.getMessage()); + throw e; + }finally { + finalAuditMetricsLogProcessor(ActionRequest.UPDATE_ACTION.name()); + } + } + + @Override + public Response deleteAction(String actionInvariantUuId, HttpServletRequest servletRequest) { + try { + log.debug(" entering API deleteAction "); + initializeRequestMDC(servletRequest, actionInvariantUuId, ActionRequest.DELETE_ACTION); + Map errorMap = validateRequestHeaders(servletRequest); + if (errorMap.isEmpty()) { + String user = servletRequest.getRemoteUser(); + actionManager.deleteAction(actionInvariantUuId, user); + } else { + checkAndThrowError(errorMap); + } + actionLogPostProcessor(StatusCode.COMPLETE, true); + log.debug(" exit API deleteAction "); + return Response.ok(new ActionResponseDto()).build(); + }catch (ActionException e){ + actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + log.error(MDC.get(ERROR_DESCRIPTION)); + throw e; + }catch (Exception e){ + actionLogPostProcessor(StatusCode.ERROR,true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(e.getMessage()); + throw e; + }finally { + finalAuditMetricsLogProcessor(ActionRequest.DELETE_ACTION.name()); + } + } + + @Override + public Response actOnAction(String actionInvariantUuId, String requestJson, + HttpServletRequest servletRequest) { + Response response = null; + try { + initializeRequestMDC(servletRequest,actionInvariantUuId,ActionRequest.ACTION_VERSIONING); + log.debug("entering actOnAction with invariantUUID= "+ actionInvariantUuId + " and requestJSON= "+ requestJson ); + Map errorMap = validateRequestHeaders(servletRequest); + Map requestBodyErrors = + validateRequestBody(REQUEST_TYPE_VERSION_ACTION, requestJson); + errorMap.putAll(requestBodyErrors); + ActionVersionDto versionDTO = JsonUtil.json2Object(requestJson, ActionVersionDto.class); + checkAndThrowError(errorMap); + + String status = versionDTO.getStatus(); + Action action = new Action(); + String user = servletRequest.getRemoteUser(); + switch (status) { + case "Checkout": + action = actionManager.checkout(actionInvariantUuId, user); + break; + case "Undo_Checkout": + actionManager.undoCheckout(actionInvariantUuId, user); + StringWrapperResponse responseText = new StringWrapperResponse(); + responseText.setValue(ActionConstants.UNDO_CHECKOUT_RESPONSE_TEXT); + response = Response + .status(Response.Status.OK) + .entity(responseText) + .build(); + return response; + case "Checkin": + action = actionManager.checkin(actionInvariantUuId, user); + break; + case "Submit": + action = actionManager.submit(actionInvariantUuId, user); + break; + default: + throw new ActionException(ACTION_INVALID_PARAM_CODE, + String.format(ACTION_UNSUPPORTED_OPERATION, status)); + } + + ActionResponseDto actionResponseDto = new ActionResponseDto(); + new MapActionToActionResponseDto().doMapping(action, actionResponseDto); + response = Response.ok(actionResponseDto).build(); + actionLogPostProcessor(StatusCode.COMPLETE,true); + }catch (ActionException e){ + actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + log.error(MDC.get(ERROR_DESCRIPTION)); + throw e; + }catch (Exception e){ + actionLogPostProcessor(StatusCode.ERROR,true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(e.getMessage()); + throw e; + }finally { + finalAuditMetricsLogProcessor(ActionRequest.ACTION_VERSIONING.name()); + log.debug("exit actOnAction with invariantUUID= "+ actionInvariantUuId + " and requestJSON= "+ requestJson ); + } + return response; + } + + @Override + public Response uploadArtifact(String actionInvariantUuId, + String artifactName, + String artifactLabel, + String artifactCategory, + String artifactDescription, + String artifactProtection, + String checksum, + Attachment artifactToUpload, + HttpServletRequest servletRequest) { + Response response = null; + try { + initializeRequestMDC(servletRequest,actionInvariantUuId, ActionRequest.UPLOAD_ARTIFACT); + log.debug("entering uploadArtifact with actionInvariantUUID= "+ actionInvariantUuId + "artifactName= "+ artifactName ); + response = uploadArtifactInternal(actionInvariantUuId, artifactName, artifactLabel, artifactCategory, artifactDescription, artifactProtection, checksum, artifactToUpload, servletRequest); + actionLogPostProcessor(StatusCode.COMPLETE,true); + log.debug("exiting uploadArtifact with actionInvariantUUID= "+ actionInvariantUuId + "artifactName= "+ artifactName ); + }catch (ActionException e){ + actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + log.error(MDC.get(ERROR_DESCRIPTION)); + throw e; + }catch (Exception e){ + actionLogPostProcessor(StatusCode.ERROR,true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(e.getMessage()); + throw e; + }finally { + finalAuditMetricsLogProcessor(ActionRequest.UPLOAD_ARTIFACT.name()); + } + log.debug("exiting uploadArtifact with actionInvariantUUID= "+ actionInvariantUuId + "artifactName= "+ artifactName ); + return response; + } + + private Response uploadArtifactInternal(String actionInvariantUuId, + String artifactName, + String artifactLabel, + String artifactCategory, + String artifactDescription, + String artifactProtection, + String checksum, + Attachment artifactToUpload, + HttpServletRequest servletRequest) { + ListResponseWrapper responseList = null; + byte[] payload = null; + Map errorMap = validateRequestHeaders(servletRequest); + //Artifact name empty validation + if(StringUtils.isEmpty(artifactName)){ + errorMap.put(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_MISSING_MANDATORY_PARAM + ARTIFACT_NAME); + }else{ + //Artifact name syntax check for whitespaces and invalid characters + if(artifactName.matches(invalidFilenameRegex)){ + errorMap.put(ACTION_ARTIFACT_INVALID_NAME_CODE, ACTION_ARTIFACT_INVALID_NAME); + } + } + + //Content-Type Header Validation + String contentType = servletRequest.getContentType(); + if(StringUtils.isEmpty(contentType)){ + errorMap.put(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_CONTENT_TYPE_INVALID); + } + + if(artifactToUpload == null){ + throw new ActionException(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_MISSING_MANDATORY_PARAM + ARTIFACT_FILE); + } + + InputStream artifactInputStream = null; + try { + artifactInputStream = artifactToUpload.getDataHandler().getInputStream(); + } catch (IOException e) { + throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ARTIFACT_READ_FILE_ERROR); + } + + payload = FileUtils.toByteArray(artifactInputStream); + //Validate Artifact size + if(payload != null && payload.length > MAX_ACTION_ARTIFACT_SIZE){ + throw new ActionException(ACTION_ARTIFACT_TOO_BIG_ERROR_CODE, ACTION_ARTIFACT_TOO_BIG_ERROR); + } + + //Validate Checksum + if(StringUtils.isEmpty(checksum) || !checksum.equalsIgnoreCase(calculateCheckSum(payload))){ + errorMap.put(ACTION_ARTIFACT_CHECKSUM_ERROR_CODE, ACTION_REQUEST_ARTIFACT_CHECKSUM_ERROR); + } + + //Validate artifact protection values + if(StringUtils.isEmpty(artifactProtection)) + artifactProtection = ActionArtifactProtection.readWrite.name(); + + if(!artifactProtection.equals(ActionArtifactProtection.readOnly.name()) && !artifactProtection.equals(ActionArtifactProtection.readWrite.name())){ + errorMap.put(ACTION_ARTIFACT_INVALID_PROTECTION_CODE, ACTION_REQUEST_ARTIFACT_INVALID_PROTECTION_VALUE); + } + + ActionArtifact uploadedArtifact = new ActionArtifact(); + if(errorMap.isEmpty()){ + String user = servletRequest.getRemoteUser(); + ActionArtifact upload = new ActionArtifact(); + upload.setArtifactName(artifactName); + upload.setArtifactLabel(artifactLabel); + upload.setArtifactDescription(artifactDescription); + upload.setArtifact(payload); + upload.setArtifactCategory(artifactCategory); + upload.setArtifactProtection(artifactProtection); + uploadedArtifact = actionManager.uploadArtifact(upload, actionInvariantUuId, user); + } + else{ + checkAndThrowError(errorMap); + } + return Response.ok(uploadedArtifact).build(); + } + + @Override + public Response downloadArtifact(String actionUuId, String artifactUuId, + HttpServletRequest servletRequest) { + Response response = null; + try { + initializeRequestMDC(servletRequest, "", ActionRequest.DOWNLOAD_ARTIFACT); + log.debug(" entering downloadArtifact with actionUUID= " + actionUuId + " and artifactUUID= " + artifactUuId); + response = downloadArtifactInternal(actionUuId, artifactUuId, servletRequest); + actionLogPostProcessor(StatusCode.COMPLETE, true); + }catch (ActionException e){ + actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + log.error(MDC.get(ERROR_DESCRIPTION)); + throw e; + }catch (Exception e){ + actionLogPostProcessor(StatusCode.ERROR,true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(e.getMessage()); + throw e; + }finally { + finalAuditMetricsLogProcessor(ActionRequest.DOWNLOAD_ARTIFACT.name()); + } + log.debug(" exit downloadArtifact with actionUUID= " + actionUuId + " and artifactUUID= " + artifactUuId); + return response; + } + + public Response downloadArtifactInternal(String actionUuId, String artifactUuId, + HttpServletRequest servletRequest) { + ActionArtifact actionartifact = null; + Map errorMap = validateRequestHeaders(servletRequest); + Map queryParamErrors = validateQueryParam(actionUuId); + errorMap.putAll(queryParamErrors); + queryParamErrors = validateQueryParam(artifactUuId); + errorMap.putAll(queryParamErrors); + if (errorMap.isEmpty()) { + actionartifact = actionManager.downloadArtifact(actionUuId, artifactUuId); + } else { + checkAndThrowError(errorMap); + } + + return createArtifactDownloadResponse(actionartifact); + } + + @Override + public Response deleteArtifact(String actionInvariantUuId, String artifactUuId, + HttpServletRequest servletRequest) { + Response response=null; + try { + initializeRequestMDC(servletRequest, actionInvariantUuId, ActionRequest.DELETE_ARTIFACT); + log.debug(" entering deleteArtifact with actionInvariantUUID= " + actionInvariantUuId + " and artifactUUID= " + artifactUuId); + response = deleteArtifactInternal(actionInvariantUuId, artifactUuId, servletRequest); + log.debug(" exit deleteArtifact with actionInvariantUUID= " + actionInvariantUuId + " and artifactUUID= " + artifactUuId); + actionLogPostProcessor(StatusCode.COMPLETE, true); + }catch (ActionException e){ + actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + log.error(MDC.get(ERROR_DESCRIPTION)); + throw e; + }catch (Exception e){ + actionLogPostProcessor(StatusCode.ERROR,true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(e.getMessage()); + throw e; + }finally { + finalAuditMetricsLogProcessor(ActionRequest.DELETE_ARTIFACT.name()); + } + return response; + } + + public Response deleteArtifactInternal(String actionInvariantUuId, String artifactUuId, + HttpServletRequest servletRequest) { + Map errorMap = validateRequestHeaders(servletRequest); + Map queryParamErrors = validateQueryParam(actionInvariantUuId); + errorMap.putAll(queryParamErrors); + queryParamErrors = validateQueryParam(artifactUuId); + errorMap.putAll(queryParamErrors); + if (errorMap.isEmpty()) { + actionManager + .deleteArtifact(actionInvariantUuId, artifactUuId, servletRequest.getRemoteUser()); + } else { + checkAndThrowError(errorMap); + } + return Response.ok().build(); + } + + @Override + public Response updateArtifact(String actionInvariantUuId, String artifactUuId, + String artifactName, String artifactLabel, String artifactCategory, + String artifactDescription, String artifactProtection, + String checksum, Attachment artifactToUpdate, + HttpServletRequest servletRequest) { + Response response=null; + log.debug(" entering updateArtifact with actionInvariantUUID= " + actionInvariantUuId + " and artifactUUID= " + artifactUuId + " and artifactName= "+artifactName+" and artifactLabel= "+ artifactLabel+" and artifactCategory= "+artifactCategory+" and artifactDescription= "+artifactDescription+" and artifactProtection= "+artifactProtection+" and checksum= "+checksum); + try { + initializeRequestMDC(servletRequest, actionInvariantUuId, ActionRequest.UPDATE_ARTIFACT); + response = updateArtifactInternal(actionInvariantUuId, artifactUuId, artifactName, artifactLabel, artifactCategory, artifactDescription, artifactProtection, checksum, artifactToUpdate, servletRequest); + actionLogPostProcessor(StatusCode.COMPLETE, true); + }catch (ActionException e){ + actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + log.error(MDC.get(ERROR_DESCRIPTION)); + throw e; + }catch (Exception e){ + actionLogPostProcessor(StatusCode.ERROR,true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(e.getMessage()); + throw e; + }finally { + finalAuditMetricsLogProcessor(ActionRequest.UPDATE_ARTIFACT.name()); + } + log.debug(" exit updateArtifact with actionInvariantUUID= " + actionInvariantUuId + " and artifactUUID= " + artifactUuId + " and artifactName= "+artifactName+" and artifactLabel= "+ artifactLabel+" and artifactCategory= "+artifactCategory+" and artifactDescription= "+artifactDescription+" and artifactProtection= "+artifactProtection+" and checksum= "+checksum); + return response; + } + + public Response updateArtifactInternal(String actionInvariantUuId, String artifactUuId, + String artifactName, String artifactLabel, String artifactCategory, + String artifactDescription, String artifactProtection, + String checksum, Attachment artifactToUpdate, + HttpServletRequest servletRequest) { + byte[] payload = null; + Map errorMap = validateRequestHeaders(servletRequest); + //Content-Type Header Validation + String contentType = servletRequest.getContentType(); + if (StringUtils.isEmpty(contentType)) { + errorMap.put(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_CONTENT_TYPE_INVALID); + } + + if (artifactToUpdate != null) { + InputStream artifactInputStream = null; + try { + artifactInputStream = artifactToUpdate.getDataHandler().getInputStream(); + } catch (IOException e) { + throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ARTIFACT_READ_FILE_ERROR); + } + + payload = FileUtils.toByteArray(artifactInputStream); + //Validate Artifact size + if (payload != null && payload.length > MAX_ACTION_ARTIFACT_SIZE) { + throw new ActionException(ACTION_ARTIFACT_TOO_BIG_ERROR_CODE, + ACTION_ARTIFACT_TOO_BIG_ERROR); + } + + //Validate Checksum + if (StringUtils.isEmpty(checksum) || !checksum.equalsIgnoreCase(calculateCheckSum(payload))) { + errorMap.put(ACTION_ARTIFACT_CHECKSUM_ERROR_CODE, ACTION_REQUEST_ARTIFACT_CHECKSUM_ERROR); + } + } + + if (artifactProtection != null && (artifactProtection.isEmpty() || + (!artifactProtection.equals(ActionArtifactProtection.readOnly.name()) && + !artifactProtection.equals(ActionArtifactProtection.readWrite.name())))) { + errorMap.put(ACTION_ARTIFACT_INVALID_PROTECTION_CODE, + ACTION_REQUEST_ARTIFACT_INVALID_PROTECTION_VALUE); + } + + ActionArtifact updateArtifact = new ActionArtifact(); + if (errorMap.isEmpty()) { + String user = servletRequest.getRemoteUser(); + ActionArtifact update = new ActionArtifact(); + update.setArtifactUuId(artifactUuId); + update.setArtifactName(artifactName); + update.setArtifactLabel(artifactLabel); + update.setArtifactDescription(artifactDescription); + update.setArtifact(payload); + update.setArtifactCategory(artifactCategory); + update.setArtifactProtection(artifactProtection); + actionManager.updateArtifact(update, actionInvariantUuId, user); + } else { + checkAndThrowError(errorMap); + } + return Response.ok().build(); + //return Response.status(Response.Status.OK).entity("Artifact successfully updated").build(); + } + + /** + * Get List of all actions + */ + private Response getAllActions(HttpServletRequest servletRequest) { + ListResponseWrapper responseList = null; + Map errorMap = validateRequestHeaders(servletRequest); + if (errorMap.isEmpty()) { + List actions = actionManager.getFilteredActions(FILTER_TYPE_NONE, null); + responseList = createResponse(actions); + } else { + checkAndThrowError(errorMap); + } + + return Response.ok(responseList).build(); + } + + /** + * Get Actions by ECOMP component ID + */ + private Response getActionsByECOMPComponent(String componentID, + HttpServletRequest servletRequest) { + ListResponseWrapper responseList = null; + Map errorMap = validateRequestHeaders(servletRequest); + ; + Map queryParamErrors = validateQueryParam(componentID); + errorMap.putAll(queryParamErrors); + if (errorMap.isEmpty()) { + List actions = + actionManager.getFilteredActions(FILTER_TYPE_ECOMP_COMPONENT, componentID); + responseList = createResponse(actions); + } else { + checkAndThrowError(errorMap); + } + return Response.ok(responseList).build(); + } + + /** + * Get Actions by Model ID + */ + private Response getActionsByModel(String modelId, HttpServletRequest servletRequest) { + ListResponseWrapper responseList = null; + Map errorMap = validateRequestHeaders(servletRequest); + Map queryParamErrors = validateQueryParam(modelId); + errorMap.putAll(queryParamErrors); + if (errorMap.isEmpty()) { + List actions = actionManager.getFilteredActions(FILTER_TYPE_MODEL, modelId); + responseList = createResponse(actions); + } else { + checkAndThrowError(errorMap); + } + return Response.ok(responseList).build(); + } + + /** + * Get all actions with given action name + */ + private Response getActionsByName(String name, HttpServletRequest servletRequest) { + ListResponseWrapper responseList = null; + Map errorMap = validateRequestHeaders(servletRequest); + Map queryParamErrors = validateQueryParam(name); + errorMap.putAll(queryParamErrors); + if (errorMap.isEmpty()) { + List actions = actionManager.getFilteredActions(FILTER_TYPE_NAME, name); + responseList = createResponse(actions); + } else { + checkAndThrowError(errorMap); + } + return Response.ok(responseList).build(); + } + + /** + * Get an action with given ActionUUID + */ + private Response getActionsByUniqueID(String actionUUID, HttpServletRequest servletRequest, + String actionInvariantUUID) { + Map errorMap = validateRequestHeaders(servletRequest); + Map responseDTO = new LinkedHashMap<>(); + Map queryParamErrors = validateQueryParam(actionUUID); + errorMap.putAll(queryParamErrors); + if (errorMap.isEmpty()) { + Action action = actionManager.getActionsByActionUuId(actionUUID); + if (action.getActionInvariantUuId() != null && + action.getActionInvariantUuId().equalsIgnoreCase(actionInvariantUUID)) { + responseDTO = JsonUtil.json2Object(action.getData(), LinkedHashMap.class); + responseDTO.put(STATUS, action.getStatus().name()); + responseDTO.put(TIMESTAMP, getUTCDateStringFromTimestamp(action.getTimestamp())); + responseDTO.put(UPDATED_BY, action.getUser()); + } else { + throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST); + } + } else { + checkAndThrowError(errorMap); + } + return Response.ok(responseDTO).build(); + } + + /** + * Get all actions with given Vendor Name + */ + private Response getActionsByVendor(String vendor, HttpServletRequest servletRequest) { + //Validate request syntax before passing to the manager + ListResponseWrapper responseList = null; + Map errorMap = validateRequestHeaders(servletRequest); + Map queryParamErrors = validateQueryParam(vendor); + errorMap.putAll(queryParamErrors); + if (errorMap.isEmpty()) { + List actions = actionManager.getFilteredActions(FILTER_TYPE_VENDOR, vendor); + responseList = createResponse(actions); + } else { + checkAndThrowError(errorMap); + } + return Response.ok(responseList).build(); + } + + /** + * Get all actions with given Category Name + */ + private Response getActionsByCategory(String category, HttpServletRequest servletRequest) { + //Validate request syntax before passing to the manager + ListResponseWrapper responseList = null; + Map errorMap = validateRequestHeaders(servletRequest); + Map queryParamErrors = validateQueryParam(category); + errorMap.putAll(queryParamErrors); + if (errorMap.isEmpty()) { + List actions = actionManager.getFilteredActions(FILTER_TYPE_CATEGORY, category); + responseList = createResponse(actions); + } else { + checkAndThrowError(errorMap); + } + return Response.ok(responseList).build(); + } + + /** + * Validates mandatory headers in the request + * + * @param servletRequest Servlet Request object + * @return Map of error codes and description found in the request headers + */ + private Map validateRequestHeaders(HttpServletRequest servletRequest) { + Map errorMap = new LinkedHashMap<>(); + //Syntactic generic request parameter validations + String ecompRequestId = servletRequest.getHeader(X_ECOMP_REQUEST_ID_HEADER_PARAM); + if (StringUtils.isEmpty(ecompRequestId)) { + errorMap.put(ACTION_INVALID_REQUEST_ID_CODE, ACTION_REQUEST_ECOMP_REQUEST_ID_INVALID); + } + + String ecompInstanceId = servletRequest.getHeader(X_ECOMP_INSTANCE_ID_HEADER_PARAM); + if (StringUtils.isEmpty(ecompInstanceId)) { + errorMap.put(ACTION_INVALID_INSTANCE_ID_CODE, ACTION_REQUEST_ECOMP_INSTANCE_ID_INVALID); + } + return errorMap; + } + + /** + * Validates query parameter in the request + * + * @param queryParam Query Parameter to be validated + * @return Map of error codes and description found in the query parameter + */ + private Map validateQueryParam(String queryParam) { + Map queryParamErrors = new LinkedHashMap<>(); + if (StringUtils.isEmpty(queryParam)) { + queryParamErrors + .put(ACTION_INVALID_PARAM_CODE, ACTION_REQUEST_MISSING_MANDATORY_PARAM + queryParam); + } + return queryParamErrors; + } + + /** + * Validate request body based on request type + * + * @param requestJSON Raw request json body as string + * @return Map of error codes and description found in the request body + */ + private Map validateRequestBody(String requestType, String requestJSON) { + Map requestBodyErrorMap = new LinkedHashMap<>(); + if (StringUtils.isEmpty(requestJSON) || requestJSON.equals(REQUEST_EMPTY_BODY)) { + requestBodyErrorMap.put(ACTION_INVALID_REQUEST_BODY_CODE, ACTION_REQUEST_BODY_EMPTY); + } else { + switch (requestType) { + case REQUEST_TYPE_CREATE_ACTION: + case REQUEST_TYPE_UPDATE_ACTION: + //Semantic request specific validations + Action action = JsonUtil.json2Object(requestJSON, Action.class); + if (StringUtils.isEmpty(action.getName())) { + setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_PARAM_NAME, + requestBodyErrorMap); + } else { + //Added check for action name not allowing whitespaces + if (action.getName().matches(whitespaceRegex)) { + requestBodyErrorMap + .put(ACTION_ARTIFACT_INVALID_NAME_CODE, ACTION_REQUEST_INVALID_NAME); + } + } + + if (StringUtils.isEmpty(action.getEndpointUri())) { + setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_PARAM_END_POINT_URI, + requestBodyErrorMap); + } + if (action.getSupportedModels() != null && + !isIDPresentInMap(action.getSupportedModels(), SUPPORTED_MODELS_VERSION_ID)) { + setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, + ACTION_REQUEST_PARAM_SUPPORTED_MODELS, requestBodyErrorMap); + } + if (action.getSupportedComponents() != null && + !isIDPresentInMap(action.getSupportedComponents(), SUPPORTED_COMPONENTS_ID)) { + setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, + ACTION_REQUEST_PARAM_SUPPORTED_COMPONENTS, requestBodyErrorMap); + } + if (action.getArtifacts() != null) { + setErrorValue(ACTION_UPDATE_NOT_ALLOWED_CODE, ACTION_REQUEST_ARTIFACT_OPERATION_ALLOWED, + requestBodyErrorMap); + } + break; + } + + } + return requestBodyErrorMap; + } + + /** + * Populates Given Error Map with Given Error Code and Error MEssage + */ + private void setErrorValue(String key, String message, Map errorMap) { + String errorMessage = errorMap.get(key); + if (errorMessage != null) { + message = errorMessage + ", " + message; + } else { + switch (key) { + case ACTION_REQUEST_INVALID_GENERIC_CODE: + message = ACTION_REQUEST_MISSING_MANDATORY_PARAM + message; + break; + } + } + errorMap.put(key, message); + } + + /** + * Returns true if given key exists in List of HashMap + */ + private boolean isIDPresentInMap(List> map, String idName) { + if (map != null && !map.isEmpty()) { + for (HashMap entry : map) { + if (StringUtils.isEmpty(entry.get(idName))) { + return false; + } + } + } + return true; + } + + /** + * @throws ActionException if given ErrorMap is not empty. + * All error messages at given time are thrown in one single exception + */ + private void checkAndThrowError(Map errorMap) { + if (errorMap.size() > 1) { + //Multiple errors detected .. Send the response with a common error code for multiple errors + throw new ActionException(ACTION_REQUEST_INVALID_GENERIC_CODE, + StringUtils.join(errorMap.values(), ", ")); + } else if (errorMap.size() == 1) { + String svcPolicyExceptionCode = errorMap.entrySet().iterator().next().getKey(); + throw new ActionException(svcPolicyExceptionCode, + errorMap.get(svcPolicyExceptionCode)); + } + } + + /** + * Populates ActionResponseDto based on given Action + */ + private ActionResponseDto createResponseDTO(Action action) { + String data = action.getData(); + ActionResponseDto responseDTO = JsonUtil.json2Object(data, ActionResponseDto.class); + responseDTO.setStatus(action.getStatus().name()); + responseDTO.setTimestamp(getUTCDateStringFromTimestamp(action.getTimestamp())); + //if(!action.getUser().equals(DELETE_ACTION_USER)) + responseDTO.setUpdatedBy(action.getUser()); + return responseDTO; + } + + /** + * Creates response based on given list of actions + */ + private ListResponseWrapper createResponse(List actions) { + ListResponseWrapper responseList = new ListResponseWrapper(); + for (Action action : actions) { + ActionResponseDto responseDTO = createResponseDTO(action); + responseList.add(responseDTO); + } + return responseList; + } + + + private Response createArtifactDownloadResponse(ActionArtifact actionartifact) { + if (actionartifact != null && actionartifact.getArtifact() != null) { + byte[] artifactsBytes = actionartifact.getArtifact(); + File artifactFile = new File(actionartifact.getArtifactName()); + try { + FileOutputStream fos = new FileOutputStream(artifactFile); + fos.write(artifactsBytes); + fos.close(); + } catch (IOException e) { + throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, + ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + } + Response.ResponseBuilder responseBuilder = Response.ok(artifactFile); + responseBuilder.header("Content-Disposition", + "attachment; filename=" + actionartifact.getArtifactName()); + responseBuilder.header("Content-MD5", CalcMD5CheckSum(artifactsBytes)); + responseBuilder.header("Content-Length", artifactFile.length()); + return responseBuilder.build(); + } else { + throw new ActionException(ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE, + ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST); + } + } + + private String CalcMD5CheckSum(byte[] input) { + String checksum = null; + if (input != null) { + checksum = DigestUtils.md5Hex(input).toUpperCase(); + System.out.println("checksum : " + checksum); + } + return checksum; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml new file mode 100644 index 0000000000..18a52bd940 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + org.openecomp.sdc.onboarding + action-library-rest + 1.0.0-SNAPSHOT + ../ + + + action-library-rest-types + action-library-rest-types + + + + + + org.openecomp.sdc + openecomp-sdc-common-rest + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-action-api + ${project.version} + + + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ActionResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ActionResponseDto.java new file mode 100644 index 0000000000..ff2a934f83 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ActionResponseDto.java @@ -0,0 +1,149 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.action.types; + + +import java.util.HashMap; +import java.util.List; + +/** + * Defines DTO used for Action Response. + */ +public class ActionResponseDto { + + String actionUuId; + String actionInvariantUuId; + String name; + String displayName; + String version; + String description; + String status; + String timestamp; + String updatedBy; + List vendorList; + List categoryList; + List> supportedModels; + List> supportedComponents; + + public String getActionUuId() { + return actionUuId; + } + + public void setActionUuId(String actionUuId) { + this.actionUuId = actionUuId; + } + + public String getActionInvariantUuId() { + return actionInvariantUuId; + } + + public void setActionInvariantUuId(String actionInvariantUuId) { + this.actionInvariantUuId = actionInvariantUuId; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List getCategoryList() { + return categoryList; + } + + public void setCategoryList(List categoryList) { + this.categoryList = categoryList; + } + + public List getVendorList() { + return vendorList; + } + + public void setVendorList(List vendorList) { + this.vendorList = vendorList; + } + + public List> getSupportedComponents() { + return supportedComponents; + } + + public void setSupportedComponents(List> supportedComponents) { + this.supportedComponents = supportedComponents; + } + + public List> getSupportedModels() { + return supportedModels; + } + + public void setSupportedModels(List> supportedModels) { + this.supportedModels = supportedModels; + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timeStamp) { + this.timestamp = timeStamp; + } + + public String getUpdatedBy() { + return updatedBy; + } + + public void setUpdatedBy(String updatedBy) { + this.updatedBy = updatedBy; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ActionVersionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ActionVersionDto.java new file mode 100644 index 0000000000..1b3a5cb445 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ActionVersionDto.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.action.types; + +/** + * Defines DTO for capturing input for versioning operations. + */ +public class ActionVersionDto { + + String status; + + public String getStatus() { + return status; + } + + public void setStatus(String workflowActionStatus) { + this.status = workflowActionStatus.trim(); + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ListResponseWrapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ListResponseWrapper.java new file mode 100644 index 0000000000..0ae8504db5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ListResponseWrapper.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.action.types; + +import org.openecomp.sdc.action.types.EcompComponent; + +import java.util.ArrayList; +import java.util.List; + +/** + * Defines DTO used for creating Response with list of {@link ActionResponseDto } + * or list of {@link EcompComponent }. + */ +public class ListResponseWrapper { + + List actionList; + List componentList; + List versions; + + + public ListResponseWrapper() { + this.actionList = new ArrayList<>(); + } + + public List getVersions() { + return versions; + } + + public void setVersions(List versions) { + this.versions = versions; + } + + public List getActionList() { + return actionList; + } + + public void setActionList(List actionList) { + this.actionList = actionList; + } + + public List getComponentList() { + return componentList; + } + + public void setComponentList(List componentList) { + this.componentList = componentList; + } + + public void add(ActionResponseDto e0) { + this.getActionList().add(e0); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml new file mode 100644 index 0000000000..482675fb53 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml @@ -0,0 +1,22 @@ + + + 4.0.0 + + org.openecomp.sdc + openecomp-sdc-rest-webapp + 1.0.0-SNAPSHOT + ../ + + org.openecomp.sdc.onboarding + action-library-rest + action-library-rest + pom + + + + /action-library-rest-services + /action-library-rest-types + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml new file mode 100644 index 0000000000..a5979798d2 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + + + org.openecomp.sdc + application-config-rest + 1.0.0-SNAPSHOT + + + application-config-rest-services + + + + + + io.swagger + swagger-annotations + 1.5.3 + + + javax.ws.rs + javax.ws.rs-api + ${ws.rs.version} + + + org.springframework + spring-context + ${spring.framework.version} + + + javax.inject + javax.inject + 1 + + + org.openecomp.sdc + openecomp-sdc-application-config-manager + ${project.version} + + + org.openecomp.sdc + application-config-rest-types + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-common-rest + ${project.version} + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + ${cxf.version} + + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java new file mode 100644 index 0000000000..df743a6a93 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.applicationconfig.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import org.openecomp.sdcrests.applicationconfiguration.types.ConfigurationDataDto; +import org.springframework.validation.annotation.Validated; + +import java.io.InputStream; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + + +@Path("/v1.0/application-configuration") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Application Configuration") +@Validated +public interface ApplicationConfiguration { + + @POST + @Path("/") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @ApiOperation(value = "Insert JSON schema into application config table") + Response insertToTable(@QueryParam("namespace") String namespace, @QueryParam("key") String key, + @Multipart("value") InputStream fileContainingSchema); + + + @GET + @Path("/{namespace}/{key}") + @ApiOperation(value = "Get JSON schema by namespace and key", + response = ConfigurationDataDto.class) + Response getFromTable(@PathParam("namespace") String namespace, @PathParam("key") String key); + + + @GET + @Path("/{namespace}") + @ApiOperation(value = "Get List of keys and values by namespace", + responseContainer = "List") + Response getListOfConfigurationByNamespaceFromTable(@PathParam("namespace") String namespace); + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapApplicationConfigEntityToApplicationConfigDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapApplicationConfigEntityToApplicationConfigDto.java new file mode 100644 index 0000000000..4d43e37769 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapApplicationConfigEntityToApplicationConfigDto.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.applicationconfig.rest.mapping; + +import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity; +import org.openecomp.sdcrests.applicationconfiguration.types.ApplicationConfigDto; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapApplicationConfigEntityToApplicationConfigDto + extends MappingBase { + @Override + public void doMapping(ApplicationConfigEntity source, ApplicationConfigDto target) { + target.setKey(source.getKey()); + target.setValue(source.getValue()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapConfigurationDataToConfigurationDataDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapConfigurationDataToConfigurationDataDto.java new file mode 100644 index 0000000000..6865c676ec --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapConfigurationDataToConfigurationDataDto.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.applicationconfig.rest.mapping; + +import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData; +import org.openecomp.sdcrests.applicationconfiguration.types.ConfigurationDataDto; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapConfigurationDataToConfigurationDataDto + extends MappingBase { + @Override + public void doMapping(ConfigurationData source, ConfigurationDataDto target) { + target.setValue(source.getValue()); + target.setTimeStamp(source.getTimeStamp()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java new file mode 100644 index 0000000000..81f7251fdc --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.applicationconfig.rest.services; + +import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity; +import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData; +import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.sdc.applicationconfig.ApplicationConfigManager; +import org.openecomp.sdcrests.applicationconfig.rest.ApplicationConfiguration; +import org.openecomp.sdcrests.applicationconfig.rest.mapping.MapApplicationConfigEntityToApplicationConfigDto; +import org.openecomp.sdcrests.applicationconfig.rest.mapping.MapConfigurationDataToConfigurationDataDto; +import org.openecomp.sdcrests.applicationconfiguration.types.ApplicationConfigDto; +import org.openecomp.sdcrests.applicationconfiguration.types.ConfigurationDataDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.io.InputStream; +import java.util.Collection; +import javax.inject.Named; + +import javax.ws.rs.core.Response; + +@Named +@Service("applicationConfiguration") +@Scope(value = "prototype") +public class ApplicationConfigurationImpl implements ApplicationConfiguration { + + @Autowired + private ApplicationConfigManager applicationConfigManager; + + + @Override + public Response insertToTable(String namespace, String key, InputStream fileContainingSchema) { + String value = new String(FileUtils.toByteArray(fileContainingSchema)); + + applicationConfigManager.insertIntoTable(namespace, key, value); + + return Response.ok().build(); + } + + @Override + public Response getFromTable(String namespace, String key) { + ConfigurationData value = applicationConfigManager.getFromTable(namespace, key); + ConfigurationDataDto valueDto = new MapConfigurationDataToConfigurationDataDto() + .applyMapping(value, ConfigurationDataDto.class); + + return Response.ok(valueDto).build(); + } + + @Override + public Response getListOfConfigurationByNamespaceFromTable(String namespace) { + Collection applicationConfigEntities = + applicationConfigManager.getListOfConfigurationByNamespace(namespace); + GenericCollectionWrapper applicationConfigWrapper = + new GenericCollectionWrapper<>(); + MapApplicationConfigEntityToApplicationConfigDto mapper = + new MapApplicationConfigEntityToApplicationConfigDto(); + + for (ApplicationConfigEntity applicationConfigEntity : applicationConfigEntities) { + applicationConfigWrapper + .add(mapper.applyMapping(applicationConfigEntity, ApplicationConfigDto.class)); + } + + return Response.ok(applicationConfigWrapper).build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml new file mode 100644 index 0000000000..52d592d4bf --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + + org.openecomp.sdc + application-config-rest + 1.0.0-SNAPSHOT + + + org.openecomp.sdc + application-config-rest-types + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ApplicationConfigDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ApplicationConfigDto.java new file mode 100644 index 0000000000..4d2f160d51 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ApplicationConfigDto.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.applicationconfiguration.types; + +public class ApplicationConfigDto { + + private String key; + private String value; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ConfigurationDataDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ConfigurationDataDto.java new file mode 100644 index 0000000000..fcabcf5e89 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ConfigurationDataDto.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.applicationconfiguration.types; + +public class ConfigurationDataDto { + private String value; + private long timeStamp; + + public ConfigurationDataDto(String value, long timeStamp) { + this.value = value; + this.timeStamp = timeStamp; + } + + public ConfigurationDataDto() { + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public long getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(long timeStamp) { + this.timeStamp = timeStamp; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml new file mode 100644 index 0000000000..cc1fbbbe6b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-rest-webapp + 1.0.0-SNAPSHOT + + + org.openecomp.sdc + application-config-rest + pom + + + + application-config-rest-services + application-config-rest-types + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml new file mode 100644 index 0000000000..0dea1b3ff9 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml @@ -0,0 +1,183 @@ + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-rest-webapp + 1.0.0-SNAPSHOT + + org.openecomp.sdc.onboarding + onboarding-be + onboarding-rest-war + war + + + + + + org.openecomp.sdc.onboarding + vendor-license-rest-services + ${project.version} + + + org.openecomp.sdc.onboarding + vendor-software-products-rest-services + ${project.version} + + + org.openecomp.sdc.onboarding + validation-rest-services + ${project.version} + + + + org.openecomp.sdc + application-config-rest-services + ${project.version} + + + org.openecomp.sdc.onboarding + action-library-rest-services + ${project.version} + + + javax.servlet + servlet-api + ${javax.servlet.version} + + + + org.codehaus.jackson + jackson-jaxrs + ${org.codehaus.jackson.version} + + + org.codehaus.jackson + jackson-core-asl + ${org.codehaus.jackson.version} + + + javax.inject + javax.inject + 1 + + + org.openecomp.sdc + openecomp-sdc-vendor-software-product-manager + ${project.version} + + + org.eclipse.jetty + jetty-servlets + 9.0.6.v20130930 + + + org.openecomp.sdc + openecomp-sdc-application-config-manager + ${project.version} + + + org.codehaus.groovy + groovy-all + 2.4.7 + + + org.codehaus.janino + janino + compile + + + org.codehaus.janino + commons-compiler + 3.0.6 + compile + + + org.springframework + spring-web + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + org.apache.maven.plugins + maven-surefire-plugin + + + test/core/unittest/offline/** + + true + + + buildNumber + ${buildNumber} + + + + + + maven-war-plugin + 2.1.1 + + true + + + + ${basedir}/target/generated/swagger-ui + + + + + + com.github.kongchen + swagger-maven-plugin + 3.1.0 + + + + false + org.openecomp.sdcrests + http + /onboarding-api + + Rest API + v1.0, build #${buildNumber} + Rest API Documentation + + http://www.github.com/kongchen/swagger-maven-plugin + + + ${basedir}/templates/strapdown.html.hbs + ${basedir}/target/generated/api.html + ${basedir}/target/generated/swagger-ui + + + + + + compile + + generate + + + + + + + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java new file mode 100644 index 0000000000..6e9b4dbe25 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.server.filters; + +import java.io.IOException; +import java.security.Principal; +import java.util.Base64; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import javax.servlet.http.HttpServletResponse; + +public class ActionAuthenticationFilter implements Filter { + + private boolean runningOnLocal = true; + + @Override + public void destroy() { + + } + + @Override + public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) + throws IOException, ServletException { + if (runningOnLocal) { + + HttpServletRequest httpRequest = (HttpServletRequest) arg0; + String authorizationHeader = httpRequest.getHeader("Authorization"); + if (authorizationHeader != null && !authorizationHeader.isEmpty()) { + String username; + try { + String base64Credentials = + httpRequest.getHeader("Authorization").replace("Basic", "").trim(); + String decodedCredentials = new String(Base64.getDecoder().decode(base64Credentials)); + username = decodedCredentials.substring(0, decodedCredentials.indexOf(":")); + } catch (Exception e0) { + setResponseStatus((HttpServletResponse) arg1, HttpServletResponse.SC_FORBIDDEN); + return; + } + if (username.startsWith("AUTH")) { + HttpServletRequestWrapper servletRequest = new HttpServletRequestWrapper(httpRequest) { + @Override + public java.lang.String getRemoteUser() { + return getUserPrincipal().getName(); + } + + @Override + public Principal getUserPrincipal() { + return () -> username.substring(0, username.indexOf("-")); + } + + @Override + public boolean isUserInRole(String role) { + try { + ActionLibraryPrivilege requiredPrivilege = + ActionLibraryPrivilege.getPrivilege(httpRequest.getMethod()); + ActionLibraryPrivilege userPrivilege = ActionLibraryPrivilege + .valueOf(username.substring(username.indexOf("-") + 1).toUpperCase()); + return userPrivilege.ordinal() >= requiredPrivilege.ordinal(); + } catch (Exception e0) { + return false; + } + } + }; + arg2.doFilter(servletRequest, arg1); + } else { + setResponseStatus((HttpServletResponse) arg1, HttpServletResponse.SC_FORBIDDEN); + } + } else { + setResponseStatus((HttpServletResponse) arg1, HttpServletResponse.SC_UNAUTHORIZED); + } + } else { + //call super doFilter of cadi authentication filter + } + + + } + + private void setResponseStatus(HttpServletResponse response, int status) { + response.setStatus(status); + } + + @Override + public void init(FilterConfig arg0) throws ServletException { + /*runningOnLocal = System.getProperty("file.separator").equals("\\"); + if (!runningOnLocal){ + // call to super init of cadi filter as we are not running on windows + }*/ + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java new file mode 100644 index 0000000000..ba9c7537f4 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.server.filters; + +import java.io.IOException; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class ActionAuthorizationFilter implements Filter { + + private boolean runningOnLocal = true; + + @Override + public void destroy() { + } + + @Override + public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) + throws IOException, ServletException { + + if (runningOnLocal) { + HttpServletRequest httpRequest = (HttpServletRequest) arg0; + if (httpRequest.isUserInRole(httpRequest.getMethod().toUpperCase())) { + arg2.doFilter(arg0, arg1); + } else { + setResponseStatus((HttpServletResponse) arg1, HttpServletResponse.SC_FORBIDDEN); + } + } else { + //call super doFilter of cadi authorization filter with relavant info as and when available + } + + } + + private void setResponseStatus(HttpServletResponse response, int status) { + response.setStatus(status); + } + + @Override + public void init(FilterConfig arg0) throws ServletException { + /*runningOnLocal = System.getProperty("file.separator").equals("\\"); + if (!runningOnLocal){ + // call to super init of cadi filter as we are not running on windows + }*/ + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionLibraryPrivilege.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionLibraryPrivilege.java new file mode 100644 index 0000000000..c34af00830 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionLibraryPrivilege.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.server.filters; + +public enum ActionLibraryPrivilege { + + RETRIEVE, CREATE, UPDATE, DELETE; + + /** + * + * @param operation . + * @return actionLibraryPrivilege + */ + public static ActionLibraryPrivilege getPrivilege(String operation) { + + ActionLibraryPrivilege toReturn; + + switch (operation) { + + case "GET": + toReturn = RETRIEVE; + break; + case "POST": + toReturn = CREATE; + break; + case "PUT": + toReturn = UPDATE; + break; + case "DELETE": + toReturn = DELETE; + break; + default: + toReturn = null; + break; + + } + + return toReturn; + + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/DefaultOutput.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/DefaultOutput.java new file mode 100644 index 0000000000..b2e1119a78 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/DefaultOutput.java @@ -0,0 +1,182 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.server.interceptors; + +import java.io.Serializable; +import java.lang.annotation.Annotation; +import java.net.URI; +import java.util.Date; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import javax.ws.rs.core.EntityTag; +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.Link; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.NewCookie; +import javax.ws.rs.core.Response; + +public class DefaultOutput extends Response implements Serializable { + + private static final long serialVersionUID = 8061802931931401706L; + + private final int status; + private final Object entity; + private MultivaluedMap metadata; + + public DefaultOutput(int s0, Object e0) { + this.status = s0; + this.entity = e0; + } + public Object getEntity() { + return entity; + } + + @Override + public T readEntity(Class asClass) { + return null; + } + + @Override + public T readEntity(GenericType genericType) { + return null; + } + + @Override + public T readEntity(Class asClass, Annotation[] annotations) { + return null; + } + + @Override + public T readEntity(GenericType var1, Annotation[] var2) { + return null; + } + + @Override + public boolean hasEntity() throws IllegalStateException { + return false; + } + + @Override + public boolean bufferEntity() { + return false; + } + + @Override + public void close() { + } + + @Override + public MediaType getMediaType() { + return null; + } + + @Override + public Locale getLanguage() { + return null; + } + + @Override + public int getLength() { + return 0; + } + + @Override + public Set getAllowedMethods() { + return null; + } + + @Override + public Map getCookies() { + return null; + } + + @Override + public EntityTag getEntityTag() { + return null; + } + + @Override + public Date getDate() { + return null; + } + + @Override + public Date getLastModified() { + return null; + } + + @Override + public URI getLocation() { + return null; + } + + @Override + public Set getLinks() { + return null; + } + + @Override + public boolean hasLink(String s0) { + return false; + } + + @Override + public Link getLink(String s0) { + return null; + } + + @Override + public Link.Builder getLinkBuilder(String s0) { + return null; + } + + public int getStatus() { + return status; + } + + @Override + public StatusType getStatusInfo() { + return null; + } + + void addMetadata(MultivaluedMap meta) { + this.metadata = meta; + } + + public MultivaluedMap getMetadata() { + // don't worry about cloning for now + return metadata; + } + + @Override + public MultivaluedMap getStringHeaders() { + return null; + } + + @Override + public String getHeaderString(String s0) { + return null; + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/EmptyOutputOutInterceptor.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/EmptyOutputOutInterceptor.java new file mode 100644 index 0000000000..4e2f56834f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/EmptyOutputOutInterceptor.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.server.interceptors; + +import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor; +import org.apache.cxf.interceptor.Fault; +import org.apache.cxf.message.Message; +import org.apache.cxf.message.MessageContentsList; +import org.apache.cxf.phase.Phase; + +import javax.inject.Named; +import javax.ws.rs.core.Response; + +@Named +public class EmptyOutputOutInterceptor extends AbstractOutDatabindingInterceptor { + + public EmptyOutputOutInterceptor() { + // To be executed in post logical phase before marshal phase + super(Phase.POST_LOGICAL); + } + + /** + * Intercepts a message. + * Interceptors should NOT invoke handleMessage or handleFault + * on the next interceptor - the interceptor chain will + * take care of this. + * + * @param message input message. + */ + public void handleMessage(Message message) throws Fault { + //get the message + MessageContentsList objs = MessageContentsList.getContentsList(message); + if (objs.get(0) instanceof Response) { + //check if response is present but entity inside it is null the set a default entity + int status = ((Response) objs.get(0)).getStatus(); + Object entity = ((Response) objs.get(0)).getEntity(); + // in case of staus 200 and entity is null send InternalEmptyObject in output. + if (entity == null && status == 200) { + DefaultOutput defaultOutput = new DefaultOutput(status, new InternalEmptyObject()); + defaultOutput.addMetadata(((Response) objs.get(0)).getMetadata()); + objs.set(0, defaultOutput); + } + } + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/InternalEmptyObject.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/InternalEmptyObject.java new file mode 100644 index 0000000000..d2b24bde77 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/InternalEmptyObject.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.server.interceptors; + +import org.codehaus.jackson.annotate.JsonAutoDetect; + +import java.io.Serializable; + +/** + * This class is for Internal use only. + * Please don't use this class. + */ +@JsonAutoDetect +public class InternalEmptyObject implements Serializable { + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java new file mode 100644 index 0000000000..2ea0ee2f66 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.server.listeners; + + +import org.springframework.web.context.ContextLoaderListener; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +public class OnboardingAppStartupListener implements ServletContextListener { + + ContextLoaderListener springListener; + + @Override + public void contextInitialized(ServletContextEvent servletContextEvent) { + springListener = new ContextLoaderListener(); + springListener.initWebApplicationContext(servletContextEvent.getServletContext()); + } + + @Override + public void contextDestroyed(ServletContextEvent servletContextEvent) { + springListener.closeWebApplicationContext(servletContextEvent.getServletContext()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/resources/keyfile.txt b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/resources/keyfile.txt new file mode 100644 index 0000000000..d6c2c253f8 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/resources/keyfile.txt @@ -0,0 +1,27 @@ +hfLSGGYWU2SyTlltV0HVwU6o3GtrtccAU8aFwq65OHsl6JeEAirXaNl73xz2uTrfiFqVJD7GTxXr +_qlY4BnLFZ7q3KNRZ0VQssjF_REjB8p7YMkEiTzbJL0pSaI6s0GRotuM432Jbsoksh8WZeui7svx +I_KD124t73d1EpIAQwHldZXRZEoDrLjfJUSCAcmsXSu5OlIMZDKOy7vR0aXPw6Dpn9sZBcpFHFQL +Xkp63yTf81snlVBGXApwS852_u4nEYmQrGQo9u6iLRg4dodOUD7wG7jbNB_KtmIspxL87i75hJ_0 +PXkLN8H2K14Rvk9ILYjdASpPOyVMK8avylRRyRy5HFBUJfeWk4YJEPus79Ol-j3QefWxX2hEOe_Y +AcA5xYgwsYylSARWcQ7aZ8M781-CNaM1yDkFCBRNLQoOo3k_yyspfHC0fOwIOPZdh9YiXIop3MAM +FC0SdPTUQrQxlF3IOC7tfEp7Wu2XezkcbIBe8mDy7dcYa87KqrL0zRju80R_gl-UCkxMLZpEKhnB +zWxjDNOGCC4VaLMrW6uREFlanw2yg3XAXZD2vl60r1WNUrRUJcYRs9FwNkdVhKH7o_D7GLXCxlEF +ltapyC4i1xgeXiEH35WrqlmS1PexaWkRloFmpLXY56D3iqg9RYrZnqQAift20LLQ_ZMFS_fOlb8w +pu-VqjifrOthE9B375Nq-_YdMCLRAdAXf5wiMC1AlimLE6gmE6cl0SopHpmtmLX--4jy8IUSOceG +xhTKpfO_7Gnn-V5m-ourtkj_UivEiM3eIyzilamlEtac50e-mg1sEHjPvAQd7p_oqaGd4NveSUeG +_WsLUZJgKI6Nu0545J1tDmlgZ4atd1b4Mkutl1CbijYg9c6Nu_zxMs9RwN9_-C3JJJxQpBUieXFY +f38PD62P8Ihb8VmNmBhOT8abRmH7Zx1adz6fcjFtaO0wSsfWr8M04W_GrbrGO_yr7GeJwqdYEP8r +rUoQWkNRuapL09KUHhHTdc8hQoCNUx4p2H2_ADA8j6gp62z54LUQDaTOHJI3Vs6mdfP7oDr2H_VK +LLWR7fHcDzS89opwtp7NO56jpmmq4q-U9kxpY1lMYJhKBuVMCm038l_eMGL35jD6OcgOCC2GL9U9 +wfyjwumJMNIND8I3viuyouMy_B5q00v27M2im6Q814Mg5Cw-RCiKy4kjhutkqTw8hXh7RLkm-QeJ +KlsrH98snwWLaw9LBeGoMbqzHzWl93inEsTyLutMPA8xSIj5kySLIcJCXq9-RMp8cnOYy8TY9Jix +oaB2u4ofHDDrrMzKY88ZPdMiGQX2BNdsOG6o4ifSVyyYwIWBtQvtO7SDvGhRUGEV1JHloBdIos0M +87SMERYd_UPKK_yl2RaqloQZRlDSgUR7i0hoqrhtPe5Ef4cJFX_CSt_oQnEu0JatwAuwybkLLPbO +mArd3rtrOh-uR_0Y77zb7Uw4H5_oX_ANIecH0sgRcvQESaq-ioYrvS94VqvxU8ByuxqxJLMo90Rc +oOAk3pq0b-16x_WRxWTfbnnNLDSQ_DwS-Xeav1nPwm-ELy1AVEQdpgbjONThjkZp3AuljaH_1Fs4 +u0A8HeCgIa4g7jsvIRxw6zLKspYENdvoHvQLWGRpaA-vfT3i3lR0MEu53v8M9hI8U8MqJo_J0xe6 +z2mtQWPiCLtW99vTqhKOm621_GNYmp10TEXVMkXumEk2rTgLBDaFEFwpgS5LqkEOObVChd9jx9oa +DW4LjhzO1EE5twGvbTiRAJsO6j5UNTonGFLLttYKq9CMvDiBZ8-whFGOM8D2qAWYiwDCI-dLqwat +jxQP1cYKGHMS2-VJ5QJa6EINEx2zo3VmnHYCE9gM71fC26018Y2T-sQfE1MRE9SU_Xma7Qbl5OBp +IflyJCTyhZfgFlqU9f2cq12bjoNuMrgOlKwap6325LGZK1XsmsHuHmASRE4-E-qmQY7GI9oJLmbl +425swlxRA-mr1eGZU0hK3ZFjz_4clBMLJBYMFYhdGzi4VYGPzaO0z0wNJzOQf3V5NbReFjxl \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml new file mode 100644 index 0000000000..5eb2b98cd5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/jetty-web.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/jetty-web.xml new file mode 100644 index 0000000000..80d8dd70cb --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/jetty-web.xml @@ -0,0 +1,8 @@ + + + + + /onboarding-api + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..68b7758609 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,95 @@ + + + + + + + + contextConfigLocation + WEB-INF/beans-services.xml + + + + + org.openecomp.server.listeners.OnboardingAppStartupListener + + + + cross-origin + org.eclipse.jetty.servlets.CrossOriginFilter + + allowedOrigins + * + + + allowedMethods + * + + + allowedHeaders + * + + + + + AuthN + org.openecomp.server.filters.ActionAuthenticationFilter + + + AuthZ + org.openecomp.server.filters.ActionAuthorizationFilter + + + cross-origin + /* + + + AuthN + /workflow/v1.0/actions/* + + + AuthZ + /workflow/v1.0/actions/* + + + LoggingServletFilter + org.openecomp.core.logging.servlet.LoggingFilter + + + + LoggingServletFilter + /* + + + + CXFServlet + CXF Servlet + + org.apache.cxf.transport.servlet.CXFServlet + + + redirects-list + + /docs/(\S)+\.json + + + + redirect-attributes + + javax.servlet.include.request_uri + + + + redirect-servlet-name + default + + 1 + + + CXFServlet + /* + + + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/templates/markdown.hbs b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/templates/markdown.hbs new file mode 100644 index 0000000000..cc87c38244 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/templates/markdown.hbs @@ -0,0 +1,105 @@ +#{{#info}}{{title}} + + +## {{join schemes " | "}}://{{host}}{{basePath}} + + +{{description}} + +{{#contact}} +[**Contact the developer**](mailto:{{email}}) +{{/contact}} + +**Version** {{version}} + +{{#license}}[**{{name}}**]({{url}}){{/license}} + +{{/info}} + +{{#if consumes}}**Consumes:** {{join consumes ", "}}{{/if}} + +{{#if produces}}**Produces:** {{join produces ", "}}{{/if}} + +{{#if securityDefinitions}} +# Security Definitions +{{/if}} +{{> security}} + +# APIs + +{{#each paths}} +## {{@key}} +{{#this}} +{{#get}} +### GET +{{> operation}} +{{/get}} + +{{#put}} +### PUT +{{> operation}} +{{/put}} + +{{#post}} +### POST + +{{> operation}} + +{{/post}} + +{{#delete}} +### DELETE +{{> operation}} +{{/delete}} + +{{#option}} +### OPTION +{{> operation}} +{{/option}} + +{{#patch}} +### PATCH +{{> operation}} +{{/patch}} + +{{#head}} +### HEAD +{{> operation}} +{{/head}} + +{{/this}} +{{/each}} + +# Definitions +{{#each definitions}} +## {{@key}} + + + + + + + + + + {{#each this.properties}} + + + + + + + + {{/each}} +
nametyperequireddescriptionexample
{{@key}} + {{#ifeq type "array"}} + {{#items.$ref}} + {{type}}[{{basename items.$ref}}] + {{/items.$ref}} + {{^items.$ref}}{{type}}[{{items.type}}]{{/items.$ref}} + {{else}} + {{#$ref}}{{basename $ref}}{{/$ref}} + {{^$ref}}{{type}}{{#format}} ({{format}}){{/format}}{{/$ref}} + {{/ifeq}} + {{#required}}required{{/required}}{{^required}}optional{{/required}}{{#description}}{{{description}}}{{/description}}{{^description}}-{{/description}}{{example}}
+{{/each}} \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/templates/operation.hbs b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/templates/operation.hbs new file mode 100644 index 0000000000..375d4f7701 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/templates/operation.hbs @@ -0,0 +1,73 @@ +{{#deprecated}}-deprecated-{{/deprecated}} +{{summary}} + +{{description}} + +{{#if externalDocs.url}}{{externalDocs.description}}. [See external documents for more details]({{externalDocs.url}}) +{{/if}} + +{{#if security}} +#### Security +{{/if}} + +{{#security}} +{{#each this}} +* {{@key}} +{{#this}} * {{this}} +{{/this}} +{{/each}} +{{/security}} + +#### Request + +{{#if consumes}} +**Content-Type: ** {{join consumes ", "}}{{/if}} + +##### Parameters +{{#if parameters}} + + + + + + + + + +{{/if}} + +{{#parameters}} + + + + + + +{{#ifeq in "body"}} + +{{else}} + {{#ifeq type "array"}} + + {{else}} + + {{/ifeq}} +{{/ifeq}} + +{{/parameters}} +{{#if parameters}} +
NameLocated inRequiredDescriptionDefaultSchema
{{name}}{{in}}{{#if required}}yes{{else}}no{{/if}}{{description}}{{#if pattern}} (**Pattern**: `{{pattern}}`){{/if}}{{#if defaultValue}}{{defaultValue}}{{else}} - {{/if}} + {{#ifeq schema.type "array"}}Array[{{basename schema.items.$ref}}]{{/ifeq}} + {{#schema.$ref}}{{basename schema.$ref}} {{/schema.$ref}} + Array[{{items.type}}] ({{collectionFormat}}){{type}} {{#format}}({{format}}){{/format}}
+{{/if}} + + +#### Response + +{{#if produces}}**Content-Type: ** {{join produces ", "}}{{/if}} + + +| Status Code | Reason | Response Model | +|-------------|-------------|----------------| +{{#each responses}}| {{@key}} | {{description}} | {{#schema.$ref}}{{basename schema.$ref}}{{/schema.$ref}}{{#ifeq schema.type "array"}}Array[{{basename schema.items.$ref}}]{{/ifeq}}{{^schema}} - {{/schema}}| +{{/each}} \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/templates/security.hbs b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/templates/security.hbs new file mode 100644 index 0000000000..04f86e8380 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/templates/security.hbs @@ -0,0 +1,88 @@ +{{#each securityDefinitions}} +### {{@key}} +{{#this}} +{{#ifeq type "oauth2"}} + + + + + +{{#if description}} + + + + +{{/if}} +{{#if authorizationUrl}} + + + + +{{/if}} +{{#if flow}} + + + + +{{/if}} +{{#if tokenUrl}} + + + + +{{/if}} +{{#if scopes}} + + +{{#each scopes}} + + + + +{{/each}} + +{{/if}} +
type{{type}}
description{{description}}
authorizationUrl{{authorizationUrl}}
flow{{flow}}
tokenUrl{{tokenUrl}}
scopes{{@key}}{{this}}
+{{/ifeq}} +{{#ifeq type "apiKey"}} + + + + + +{{#if description}} + + + + +{{/if}} +{{#if name}} + + + + +{{/if}} +{{#if in}} + + + + +{{/if}} +
type{{type}}
description{{description}}
name{{name}}
in{{in}}
+{{/ifeq}} +{{#ifeq type "basic"}} + + + + + +{{#if description}} + + + + +{{/if}} +
type{{type}}
description{{description}}
+{{/ifeq}} +{{/this}} +{{/each}} \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/templates/strapdown.html.hbs b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/templates/strapdown.html.hbs new file mode 100644 index 0000000000..fe722ab6f1 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/templates/strapdown.html.hbs @@ -0,0 +1,11 @@ + + +API Document + + + +{{>markdown}} + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml new file mode 100644 index 0000000000..764fb84db4 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-rest-webapp + 1.0.0-SNAPSHOT + + + openecomp-sdc-common-rest + openecomp-sdc-common-rest + + + + + org.openecomp.core + openecomp-utilities-lib + ${project.version} + + + org.openecomp.core + openecomp-common-lib + ${project.version} + + + org.hibernate + hibernate-validator + ${hibernate.validator.version} + + + javax.ws.rs + javax.ws.rs-api + ${ws.rs.version} + + + + io.swagger + swagger-core + ${swagger.version} + compile + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java new file mode 100644 index 0000000000..499bd6e785 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.common; + +public class RestConstants { + public static final String USER_HEADER_PARAM = "USER_ID"; + public static final String USER_MISSING_ERROR_MSG = + "Field does not conform to predefined criteria : user : may not be null"; + public static final String INVALID_JSON_ERROR_MESSAGE = + "Field does not conform to predefined criteria : body :must be in JSON format"; +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorCodeToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorCodeToDto.java new file mode 100644 index 0000000000..cad5c69899 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorCodeToDto.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.common.mapping; + +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdcrests.common.types.ErrorCodeDto; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapErrorCodeToDto extends MappingBase { + @Override + public void doMapping(ErrorCode source, ErrorCodeDto target) { + target.setId(source.id()); + target.setCategory(source.category()); + target.setMessage(source.message()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorMessageToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorMessageToDto.java new file mode 100644 index 0000000000..83c7b15980 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorMessageToDto.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.common.mapping; + +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdcrests.common.types.ErrorMessageDto; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapErrorMessageToDto extends MappingBase { + @Override + public void doMapping(ErrorMessage source, ErrorMessageDto target) { + target.setMessage(source.getMessage()); + target.setLevel(source.getLevel()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorCodeDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorCodeDto.java new file mode 100644 index 0000000000..3615f89afc --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorCodeDto.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.common.types; + +import org.openecomp.sdc.common.errors.ErrorCategory; + +public class ErrorCodeDto { + private String id; + private String message; + private ErrorCategory category; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public ErrorCategory getCategory() { + return category; + } + + public void setCategory(ErrorCategory category) { + this.category = category; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorMessageDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorMessageDto.java new file mode 100644 index 0000000000..f63a9b0ced --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorMessageDto.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.common.types; + +import org.openecomp.sdc.datatypes.error.ErrorLevel; + +public class ErrorMessageDto { + private ErrorLevel level; + private String message; + + public ErrorLevel getLevel() { + return level; + } + + public void setLevel(ErrorLevel level) { + this.level = level; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java new file mode 100644 index 0000000000..67da814f48 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java @@ -0,0 +1,163 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.errors; + +import org.codehaus.jackson.map.JsonMappingException; +import org.hibernate.validator.internal.engine.path.PathImpl; +import org.openecomp.core.utilities.CommonMethods; +import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.common.errors.ErrorCodeAndMessage; +import org.openecomp.sdc.common.errors.GeneralErrorBuilder; +import org.openecomp.sdc.common.errors.JsonMappingErrorBuilder; +import org.openecomp.sdc.common.errors.ValidationErrorBuilder; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.validation.ConstraintViolation; +import javax.validation.ConstraintViolationException; +import javax.validation.Path; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; + +public class DefaultExceptionMapper implements ExceptionMapper { + private static final String ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE = + "errorCodesToResponseStatusMapping.json"; + private static Map errorCodeToResponseStatus = JsonUtil + .json2Object(FileUtils.getFileInputStream(ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE), + Map.class); + private static org.slf4j.Logger logger = LoggerFactory.getLogger(DefaultExceptionMapper.class); + + @Override + public Response toResponse(Exception e0) { + Response response; + if (e0 instanceof CoreException) { + response = transform(CoreException.class.cast(e0)); + } else if (e0 instanceof ConstraintViolationException) { + response = transform(ConstraintViolationException.class.cast(e0)); + + } else if (e0 instanceof JsonMappingException) { + response = transform(JsonMappingException.class.cast(e0)); + + } else { + response = transform(e0); + } + + List contentTypes = new ArrayList<>(); + contentTypes.add(MediaType.APPLICATION_JSON); + response.getMetadata().put("Content-Type", contentTypes); + return response; + } + + private Response transform(CoreException coreException) { + Response response; + ErrorCode code = coreException.code(); + logger.error(code.message(), coreException); + + if (coreException.code().category().equals(ErrorCategory.APPLICATION)) { + if (Response.Status.NOT_FOUND.name().equals(errorCodeToResponseStatus.get(code.id()))) { + response = Response + .status(Response.Status.NOT_FOUND) + .entity(toEntity(Response.Status.NOT_FOUND, code)) + .build(); + } else if (Response.Status.BAD_REQUEST.name() + .equals(errorCodeToResponseStatus.get(code.id()))) { + response = Response + .status(Response.Status.BAD_REQUEST) + .entity(toEntity(Response.Status.BAD_REQUEST, code)) + .build(); + } else { + response = Response + .status(Response.Status.EXPECTATION_FAILED) + .entity(toEntity(Response.Status.EXPECTATION_FAILED, code)) + .build(); + } + } else { + response = Response + .status(Response.Status.INTERNAL_SERVER_ERROR) + .entity(toEntity(Response.Status.INTERNAL_SERVER_ERROR, code)) + .build(); + } + + + return response; + } + + private Response transform(ConstraintViolationException validationException) { + Set> constraintViolationSet = + validationException.getConstraintViolations(); + String message; + + String fieldName = null; + if (!CommonMethods.isEmpty(constraintViolationSet)) { + // getting the first violation message for the output response. + ConstraintViolation constraintViolation = constraintViolationSet.iterator().next(); + message = constraintViolation.getMessage(); + fieldName = getFieldName(constraintViolation.getPropertyPath()); + + } else { + message = validationException.getMessage(); + } + + ErrorCode validationErrorCode = new ValidationErrorBuilder(message, fieldName).build(); + + logger.error(validationErrorCode.message(), validationException); + return Response + .status(Response.Status.EXPECTATION_FAILED) //error 417 + .entity(toEntity(Response.Status.EXPECTATION_FAILED, validationErrorCode)) + .build(); + } + + + private Response transform(JsonMappingException jsonMappingException) { + ErrorCode jsonMappingErrorCode = new JsonMappingErrorBuilder().build(); + logger.error(jsonMappingErrorCode.message(), jsonMappingException); + return Response + .status(Response.Status.EXPECTATION_FAILED) //error 417 + .entity(toEntity(Response.Status.EXPECTATION_FAILED, jsonMappingErrorCode)) + .build(); + } + + private Response transform(Exception e0) { + ErrorCode generalErrorCode = new GeneralErrorBuilder(e0.getMessage()).build(); + logger.error(generalErrorCode.message(), e0); + return Response + .status(Response.Status.INTERNAL_SERVER_ERROR) + .entity(toEntity(Response.Status.INTERNAL_SERVER_ERROR, generalErrorCode)) + .build(); + } + + private String getFieldName(Path propertyPath) { + return ((PathImpl) propertyPath).getLeafNode().toString(); + } + + private Object toEntity(Response.Status status, ErrorCode code) { + return new ErrorCodeAndMessage(status, code); + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java new file mode 100644 index 0000000000..7382ef72eb --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.mapping; + +/** + * Base class for all mapping classes. Mapping classes will perform data mapping from source object + * to target object Base class provides following
+ *
    + *
  1. provides life cycle of mapping class , first mapSimpleProperties is called and then + * mapComplexProperties is called.
  2. + *
  3. methods mapSimpleProperties and mapComplexProperties with default implementation, + * these should be overridden by concrete mapping classes for writing mapping logic.
  4. + *
+ */ + +public abstract class MappingBase { + + /** + * Method is called for starting mapping from source object to target object method sets context + * in the thread locale and than calls mapSimpleProperties and mapComplexProperties respectively. + * + * @param source : source object for mapping + * @param clazz : target Class for mapping + * @return T - instance of type T + */ + + public final T applyMapping(final S source, Class clazz) { + T target = (T) instantiateTarget(clazz); + if (source == null || target == null) { + //TODO: what what? + } else { + preMapping(source, target); + doMapping(source, target); + postMapping(source, target); + + } + return target; + + } + + /** + * This method is called before the doMapping method. + */ + + public void preMapping(final S source, T target) { + } + + /** + * The actual method that does the mapping between the source + * to target objects. + * This method is being called automatically as part of the mapper class. + * This method must be override (it is abstract) by the mapper class. + * + * @param source - the source object. + * @param target - the target object. + */ + + public abstract void doMapping(final S source, T target); + + /** + * This method is called after the doMapping method. + */ + + public void postMapping(final S source, T target) { + } + + /** + * Creates the instance of the input class. + * + * @return Object + */ + + private Object instantiateTarget(final Class clazz) { + Object object = null; + try { + object = clazz.newInstance(); + + } catch (InstantiationException | IllegalAccessException e0) { + //Do nothing + } + return object; + + } + +} + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/versioning/types/VersioningAction.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/versioning/types/VersioningAction.java new file mode 100644 index 0000000000..8cb5a061b9 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/versioning/types/VersioningAction.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.versioning.types; + +public enum VersioningAction { + Checkout, + Undo_Checkout, + Checkin, + Submit; +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java new file mode 100644 index 0000000000..b8d47e4ef3 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.wrappers; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * This class represents a generic collection wrapper to be used by paginated results. + * + * @param the type parameter + */ +public class GenericCollectionWrapper implements Serializable { + private static final long serialVersionUID = 1L; + + private List results; + private int listCount; + + /** + * Instantiates a new Generic collection wrapper. + */ + public GenericCollectionWrapper() { + this.results = new ArrayList<>(); + } + + /** + * Instantiates a new Generic collection wrapper. + * + * @param list the list + * @param listCount the list count + */ + public GenericCollectionWrapper(List list, int listCount) { + if (!list.isEmpty()) { + this.results = list; + this.listCount = listCount; + } + } + + /** + * Gets results. + * + * @return the results + */ + public List getResults() { + return results; + } + + /** + * Sets results. + * + * @param results the results + */ + public void setResults(List results) { + this.results = results; + } + + /** + * Gets list count. + * + * @return the list count + */ + public int getListCount() { + return listCount; + } + + /** + * Sets list count. + * + * @param listCount the list count + */ + public void setListCount(int listCount) { + this.listCount = listCount; + } + + /** + * Add boolean. + * + * @param e0 the e 0 + * @return the boolean + */ + public boolean add(T e0) { + if (this.getResults().add(e0)) { + this.setListCount(this.getResults().size()); + return true; + } + return false; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/StringWrapperResponse.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/StringWrapperResponse.java new file mode 100644 index 0000000000..d472eb9d14 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/StringWrapperResponse.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.wrappers; + +public class StringWrapperResponse { + private String value; + + public StringWrapperResponse() { + } + + public StringWrapperResponse(String value) { + super(); + this.value = value; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/resources/errorCodesToResponseStatusMapping.json b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/resources/errorCodesToResponseStatusMapping.json new file mode 100644 index 0000000000..e4c6962847 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/resources/errorCodesToResponseStatusMapping.json @@ -0,0 +1,9 @@ +{ + "VSP_NOT_FOUND": "NOT_FOUND", + "VSP_INVALID": "BAD_REQUEST", + "UPLOAD_INVALID" : "PRECONDITION_FAILED", + "PACKAGE_NOT_FOUND": "NOT_FOUND", + "PACKAGE_INVALID": "BAD_REQUEST", + "VENDOR_LICENSE_MODEL_NOT_FOUND": "NOT_FOUND", + "VENDOR_LICENSE_ENTITY_NOT_FOUND": "NOT_FOUND" +} \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml new file mode 100644 index 0000000000..7d20b19016 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml @@ -0,0 +1,29 @@ + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-api + 1.0.0-SNAPSHOT + ../ + + + openecomp-sdc-rest-webapp + openecomp-sdc-rest-webapp + pom + + + + + /openecomp-sdc-common-rest + /vendor-license-rest + /onboarding-rest-war + /vendor-software-products-rest + /sequence-rest + /validation-rest + /action-library-rest + /application-config-rest + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/pom.xml new file mode 100644 index 0000000000..68f021c16b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/pom.xml @@ -0,0 +1,15 @@ + + + + openecomp-sdc-rest-webapp + org.openecomp.sdc + 1.0.0-SNAPSHOT + + 4.0.0 + + sequence-rest + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/src/main/java/org/openecomp/sdcrests/service/rest/Service.java b/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/src/main/java/org/openecomp/sdcrests/service/rest/Service.java new file mode 100644 index 0000000000..3e1a107b81 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/src/main/java/org/openecomp/sdcrests/service/rest/Service.java @@ -0,0 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.service.rest; + +public interface Service { +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/src/main/java/org/openecomp/sdcrests/service/rest/services/ServiceImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/src/main/java/org/openecomp/sdcrests/service/rest/services/ServiceImpl.java new file mode 100644 index 0000000000..030d4a9c1d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/src/main/java/org/openecomp/sdcrests/service/rest/services/ServiceImpl.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.service.rest.services; + +import org.openecomp.sdcrests.service.rest.Service; + +public class ServiceImpl implements Service { +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/pom.xml new file mode 100644 index 0000000000..1db9db948c --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-rest-webapp + 1.0.0-SNAPSHOT + + + org.openecomp.sdc.onboarding + validation-rest + validation-rest + pom + + + + /validation-rest-services + /validation-rest-types + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml new file mode 100644 index 0000000000..793cdc0d42 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml @@ -0,0 +1,144 @@ + + + 4.0.0 + + + org.openecomp.sdc.onboarding + validation-rest + 1.0.0-SNAPSHOT + + + validation-rest-services + + + + + org.springframework + spring-core + ${spring.framework.version} + + + org.springframework + spring-context + ${spring.framework.version} + + + org.springframework + spring-context-support + ${spring.framework.version} + + + org.springframework + spring-web + ${spring.framework.version} + + + org.springframework + spring-beans + ${spring.framework.version} + + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + ${cxf.version} + + + + org.apache.httpcomponents + httpclient + ${http.client.version} + + + + javax.ws.rs + javax.ws.rs-api + ${ws.rs.version} + + + + + cglib + cglib-nodep + ${cglib.nodep.version} + runtime + + + + + javax.inject + javax.inject + ${javax.inject.version} + provided + + + javax.ws.rs + javax.ws.rs-api + ${ws.rs.version} + + + com.sun.jersey + jersey-core + 1.19.1 + + + javax.ws.rs + jsr311-api + + + + + io.swagger + swagger-annotations + 1.5.3 + + + org.openecomp.sdc.onboarding + validation-rest-types + ${project.version} + + + com.fasterxml.jackson.core + jackson-annotations + 2.7.4 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + 2.7.4 + + + org.codehaus.woodstox + woodstox-core-asl + 4.4.1 + + + + org.openecomp.sdc + openecomp-sdc-vendor-software-product-manager + ${project.version} + + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + test/core/unittest/offline/** + + true + + + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/Validation.java b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/Validation.java new file mode 100644 index 0000000000..5a1955c0dd --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/Validation.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.validation.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import org.springframework.validation.annotation.Validated; + +import java.io.InputStream; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + + +@Path("/v1.0/validation") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Validation") +@Validated +public interface Validation { + + + @POST + @Path("{type}/validate") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @ApiOperation(value = "Validate a package") + Response validateFile(@PathParam("type") String type, + @Multipart("validate") InputStream fileToValidate); +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/mapping/MapValidationFileResponseToValidationFileResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/mapping/MapValidationFileResponseToValidationFileResponseDto.java new file mode 100644 index 0000000000..bd8639b682 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/mapping/MapValidationFileResponseToValidationFileResponseDto.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.validation.rest.mapping; + + +import org.openecomp.sdc.validation.types.ValidationFileResponse; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.validation.types.ValidationFileResponseDto; + +public class MapValidationFileResponseToValidationFileResponseDto + extends MappingBase { + @Override + public void doMapping(ValidationFileResponse source, ValidationFileResponseDto target) { + target.setValidationData(source.getValidationData()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/services/ValidationImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/services/ValidationImpl.java new file mode 100644 index 0000000000..88a173de84 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/services/ValidationImpl.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.validation.rest.services; + +import org.openecomp.sdc.validation.UploadValidationManager; +import org.openecomp.sdc.validation.types.ValidationFileResponse; +import org.openecomp.sdcrests.validation.rest.Validation; +import org.openecomp.sdcrests.validation.rest.mapping.MapValidationFileResponseToValidationFileResponseDto; +import org.openecomp.sdcrests.validation.types.ValidationFileResponseDto; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.io.IOException; +import java.io.InputStream; +import javax.inject.Named; +import javax.ws.rs.core.Response; + + +@Named +@Service("validation") +@Scope(value = "prototype") +public class ValidationImpl implements Validation { + + @Autowired + private UploadValidationManager uploadValidationManager; + + @Override + public Response validateFile(String type, InputStream fileToValidate) { + ValidationFileResponse validationFileResponse = null; + try { + validationFileResponse = uploadValidationManager.validateFile(type, fileToValidate); + } catch (IOException e0) { + throw new RuntimeException(e0); + } + + ValidationFileResponseDto validationFileResponseDto = + new MapValidationFileResponseToValidationFileResponseDto() + .applyMapping(validationFileResponse, ValidationFileResponseDto.class); + + return Response.ok(validationFileResponseDto).build(); + } + + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml new file mode 100644 index 0000000000..fa844f891c --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml @@ -0,0 +1,32 @@ + + + 4.0.0 + + + org.openecomp.sdc.onboarding + validation-rest + 1.0.0-SNAPSHOT + ../ + + + validation-rest-types + validation-rest-types + + + + + + org.openecomp.sdc + openecomp-sdc-common-rest + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-validation-manager + ${project.version} + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/src/main/java/org/openecomp/sdcrests/validation/types/ValidationFileResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/src/main/java/org/openecomp/sdcrests/validation/types/ValidationFileResponseDto.java new file mode 100644 index 0000000000..75e59973e3 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/src/main/java/org/openecomp/sdcrests/validation/types/ValidationFileResponseDto.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.validation.types; + +import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList; + +public class ValidationFileResponseDto { + + private ValidationStructureList validationData; + + public ValidationStructureList getValidationData() { + return validationData; + } + + public void setValidationData(ValidationStructureList validationData) { + this.validationData = validationData; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml new file mode 100644 index 0000000000..6c8a7376a2 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml @@ -0,0 +1,24 @@ + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-rest-webapp + 1.0.0-SNAPSHOT + ../ + + + org.openecomp.sdc.onboarding + vendor-license-rest + vendor-license-rest + pom + + + + + /vendor-license-rest-services + /vendor-license-rest-types + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml new file mode 100644 index 0000000000..86f7ebde14 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml @@ -0,0 +1,133 @@ + + 4.0.0 + + + org.openecomp.sdc.onboarding + vendor-license-rest + 1.0.0-SNAPSHOT + ../ + + + vendor-license-rest-services + vendor-license-rest-services + + + + + + ${project.build.directory}/generated-sources/error-codes + + + + + ${project.groupId} + vendor-license-rest-types + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-vendor-license-api + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-vendor-license-manager + ${project.version} + + + + + + org.springframework + spring-core + ${spring.framework.version} + + + org.springframework + spring-context + ${spring.framework.version} + + + org.springframework + spring-context-support + ${spring.framework.version} + + + org.springframework + spring-web + ${spring.framework.version} + + + org.springframework + spring-beans + ${spring.framework.version} + + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + ${cxf.version} + + + + org.apache.httpcomponents + httpclient + ${http.client.version} + + + org.apache.httpcomponents + httpcore + ${http.client.version} + + + + javax.ws.rs + javax.ws.rs-api + ${ws.rs.version} + + + + + cglib + cglib-nodep + ${cglib.nodep.version} + runtime + + + + + javax.inject + javax.inject + ${javax.inject.version} + provided + + + org.openecomp.sdc + openecomp-sdc-vendor-software-product-manager + ${project.version} + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + test/core/unittest/offline/** + + true + + + + + + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPools.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPools.java new file mode 100644 index 0000000000..9dea767f7d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPools.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolRequestDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +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.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/v1.0/vendor-license-models/{vlmId}/entitlement-pools") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor License Model - Entitlement Pools") +@Validated +public interface EntitlementPools { + @GET + @Path("/") + @ApiOperation(value = "List vendor entitlement pools", + response = EntitlementPoolEntityDto.class, + responseContainer = "List") + Response listEntitlementPools( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) + @QueryParam("version") String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @POST + @Path("/") + @ApiOperation(value = "Create vendor entitlement pool") + Response createEntitlementPool(@Valid EntitlementPoolRequestDto request, + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") + String vlmId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_HEADER_PARAM) String user); + + @PUT + @Path("/{entitlementPoolId}") + @ApiOperation(value = "Update vendor entitlement pool") + Response updateEntitlementPool(@Valid EntitlementPoolRequestDto request, + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") + String vlmId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @PathParam("entitlementPoolId") String entitlementPoolId, + @HeaderParam(USER_HEADER_PARAM) String user); + + @GET + @Path("/{entitlementPoolId}") + @ApiOperation(value = "Get vendor entitlement pool", + response = EntitlementPoolEntityDto.class) + Response getEntitlementPool( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) + @QueryParam("version") String version, + @PathParam("entitlementPoolId") String entitlementPoolId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @DELETE + @Path("/{entitlementPoolId}") + @ApiOperation(value = "Delete vendor entitlement pool") + Response deleteEntitlementPool( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @PathParam("entitlementPoolId") String entitlementPoolId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/FeatureGroups.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/FeatureGroups.java new file mode 100644 index 0000000000..f5ad973cb0 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/FeatureGroups.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupModelDto; +import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupRequestDto; +import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupUpdateRequestDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +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.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/v1.0/vendor-license-models/{vlmId}/feature-groups") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor License Model - Feature Groups") +@Validated +public interface FeatureGroups { + + @GET + @Path("/") + @ApiOperation(value = "List vendor feature groups", + response = FeatureGroupEntityDto.class, + responseContainer = "List") + Response listFeatureGroups( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) + @QueryParam("version") String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @POST + @Path("/") + @ApiOperation(value = "Create vendor feature group") + Response createFeatureGroup(@Valid FeatureGroupRequestDto request, + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") + String vlmId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_HEADER_PARAM) String user); + + @PUT + @Path("/{featureGroupId}") + @ApiOperation(value = "Update vendor feature group") + Response updateFeatureGroup(@Valid FeatureGroupUpdateRequestDto request, + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") + String vlmId, + @PathParam("featureGroupId") String featureGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_HEADER_PARAM) String user); + + @GET + @Path("/{featureGroupId}") + @ApiOperation(value = "Get vendor feature group", + response = FeatureGroupModelDto.class) + Response getFeatureGroup( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) + @QueryParam("version") String version, + @PathParam("featureGroupId") String featureGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @DELETE + @Path("/{featureGroupId}") + @ApiOperation(value = "Delete vendor feature group") + Response deleteFeatureGroup( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @PathParam("featureGroupId") String featureGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseAgreements.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseAgreements.java new file mode 100644 index 0000000000..28d9f5a32f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseAgreements.java @@ -0,0 +1,109 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementModelDto; +import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementRequestDto; +import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementUpdateRequestDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +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.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/v1.0/vendor-license-models/{vlmId}/license-agreements") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor License Model - License Agreements") +@Validated + +public interface LicenseAgreements { + + @GET + @Path("/") + @ApiOperation(value = "List vendor license agreements", + response = LicenseAgreementEntityDto.class, + responseContainer = "List") + Response listLicenseAgreements( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) + @QueryParam("version") String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @POST + @Path("/") + @ApiOperation(value = "Create vendor license agreement") + Response createLicenseAgreement(@Valid LicenseAgreementRequestDto request, + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") + String vlmId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_HEADER_PARAM) String user); + + @PUT + @Path("/{licenseAgreementId}") + @ApiOperation(value = "Update vendor license agreement") + Response updateLicenseAgreement(@Valid LicenseAgreementUpdateRequestDto request, + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") + String vlmId, + @PathParam("licenseAgreementId") String licenseAgreementId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_HEADER_PARAM) String user); + + @GET + @Path("/{licenseAgreementId}") + @ApiOperation(value = "Get vendor license agreement", + response = LicenseAgreementModelDto.class) + Response getLicenseAgreement( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) + @QueryParam("version") String version, + @PathParam("licenseAgreementId") String licenseAgreementId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @DELETE + @Path("/{licenseAgreementId}") + @ApiOperation(value = "Delete vendor license agreement") + Response deleteLicenseAgreement( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @PathParam("licenseAgreementId") String licenseAgreementId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroups.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroups.java new file mode 100644 index 0000000000..d66945d63c --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroups.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupRequestDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +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.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/v1.0/vendor-license-models/{vlmId}/license-key-groups") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor License Model - License Key Groups") +@Validated +public interface LicenseKeyGroups { + @GET + @Path("/") + @ApiOperation(value = "List vendor license key groups", + response = LicenseKeyGroupEntityDto.class, + responseContainer = "List") + Response listLicenseKeyGroups( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) + @QueryParam("version") String version, + @HeaderParam(USER_HEADER_PARAM) String user); + + @POST + @Path("/") + @ApiOperation(value = "Create vendor license key group") + Response createLicenseKeyGroup(@Valid LicenseKeyGroupRequestDto request, + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") + String vlmId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_HEADER_PARAM) String user); + + @PUT + @Path("/{licenseKeyGroupId}") + @ApiOperation(value = "Update vendor license key group") + Response updateLicenseKeyGroup(@Valid LicenseKeyGroupRequestDto request, + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") + String vlmId, + @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_HEADER_PARAM) String user); + + @GET + @Path("/{licenseKeyGroupId}") + @ApiOperation(value = "Get vendor license key group", + response = LicenseKeyGroupEntityDto.class) + Response getLicenseKeyGroup( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) + @QueryParam("version") String version, + @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @DELETE + @Path("/{licenseKeyGroupId}") + @ApiOperation(value = "Delete vendor license key group") + Response deleteLicenseKeyGroup( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/VendorLicenseModels.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/VendorLicenseModels.java new file mode 100644 index 0000000000..15fc9bf0d9 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/VendorLicenseModels.java @@ -0,0 +1,111 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.common.RestConstants; +import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelActionRequestDto; +import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelRequestDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +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.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/v1.0/vendor-license-models") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor License Models") +@Validated +public interface VendorLicenseModels { + + @GET + @Path("/") + @ApiOperation(value = "List vendor license models", + response = VendorLicenseModelEntityDto.class, + responseContainer = "List") + Response listLicenseModels(@ApiParam( + value = "Currently supported value: 'Final' - only vendor License models with final versions " + + "will be return - with their latest final version") + @QueryParam("versionFilter") String versionFilter, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(RestConstants.USER_HEADER_PARAM) String user); + + @POST + @Path("/") + @ApiOperation(value = "Create vendor license model") + Response createLicenseModel(@Valid VendorLicenseModelRequestDto request, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(RestConstants.USER_HEADER_PARAM) String user); + + @PUT + @Path("/{vlmId}") + @ApiOperation(value = "Update vendor license model") + Response updateLicenseModel(@Valid VendorLicenseModelRequestDto request, + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") + String vlmId, @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(RestConstants.USER_HEADER_PARAM) String user); + + @GET + @Path("/{vlmId}") + @ApiOperation(value = "Get vendor license model", + response = VendorLicenseModelEntityDto.class) + Response getLicenseModel( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) + @QueryParam("version") String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_HEADER_PARAM) + String user); + + @DELETE + @Path("/{vlmId}") + @ApiOperation(value = "Delete vendor license model") + Response deleteLicenseModel( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_HEADER_PARAM) + String user); + + @PUT + @Path("/{vlmId}/actions") + @ApiOperation(value = "Update vendor license model") + Response actOnLicenseModel(@Valid VendorLicenseModelActionRequestDto request, + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") + String vlmId, @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(RestConstants.USER_HEADER_PARAM) String user); +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherDtoToChoiceOrOther.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherDtoToChoiceOrOther.java new file mode 100644 index 0000000000..28eeb29018 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherDtoToChoiceOrOther.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.ChoiceOrOtherDto; + +public class MapChoiceOrOtherDtoToChoiceOrOther + extends MappingBase { + + @Override + public void doMapping(ChoiceOrOtherDto source, ChoiceOrOther target) { + target.setChoice(source.getChoice()); + target.setOther(source.getOther()); + target.setResult(null); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherToChoiceOrOtherDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherToChoiceOrOtherDto.java new file mode 100644 index 0000000000..2d686110d5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherToChoiceOrOtherDto.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.ChoiceOrOtherDto; + +public class MapChoiceOrOtherToChoiceOrOtherDto + extends MappingBase { + + @Override + public void doMapping(ChoiceOrOther source, ChoiceOrOtherDto target) { + target.setChoice(source.getChoice()); + target.setOther(source.getOther()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java new file mode 100644 index 0000000000..c9f4ab894b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.ChoiceOrOtherDto; +import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.MultiChoiceOrOtherDto; + +public class MapEntitlementPoolEntityToEntitlementPoolEntityDto + extends MappingBase { + @Override + public void doMapping(EntitlementPoolEntity source, EntitlementPoolEntityDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setThresholdValue(source.getThresholdValue()); + target.setThresholdUnits(source.getThresholdUnit()); + target.setIncrements(source.getIncrements()); + + MapChoiceOrOtherToChoiceOrOtherDto choiceOrOtherMapper = + new MapChoiceOrOtherToChoiceOrOtherDto(); + target.setEntitlementMetric( + choiceOrOtherMapper.applyMapping(source.getEntitlementMetric(), ChoiceOrOtherDto.class)); + target.setAggregationFunction( + choiceOrOtherMapper.applyMapping(source.getAggregationFunction(), ChoiceOrOtherDto.class)); + target.setOperationalScope(new MapMultiChoiceOrOtherToMultiChoiceOrOtherDto() + .applyMapping(source.getOperationalScope(), MultiChoiceOrOtherDto.class)); + target.setTime(choiceOrOtherMapper.applyMapping(source.getTime(), ChoiceOrOtherDto.class)); + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); + + target.setReferencingFeatureGroups(source.getReferencingFeatureGroups()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java new file mode 100644 index 0000000000..fe626e374c --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; +import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolRequestDto; + +public class MapEntitlementPoolRequestDtoToEntitlementPoolEntity + extends MappingBase { + @Override + public void doMapping(EntitlementPoolRequestDto source, EntitlementPoolEntity target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setThresholdValue(source.getThresholdValue()); + target.setThresholdUnit(source.getThresholdUnits()); + target.setIncrements(source.getIncrements()); + + MapChoiceOrOtherDtoToChoiceOrOther choiceOrOtherMapper = + new MapChoiceOrOtherDtoToChoiceOrOther(); + target.setEntitlementMetric( + choiceOrOtherMapper.applyMapping(source.getEntitlementMetric(), ChoiceOrOther.class)); + target.setAggregationFunction( + choiceOrOtherMapper.applyMapping(source.getAggregationFunction(), ChoiceOrOther.class)); + target.setOperationalScope(new MapMultiChoiceOrOtherDtoToMultiChoiceOrOther() + .applyMapping(source.getOperationalScope(), MultiChoiceOrOther.class)); + target.setTime(choiceOrOtherMapper.applyMapping(source.getTime(), ChoiceOrOther.class)); + + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java new file mode 100644 index 0000000000..91239e2655 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupDescriptorDto; + + +public class MapFeatureGroupDescriptorDtoToFeatureGroupEntity + extends MappingBase { + @Override + public void doMapping(FeatureGroupDescriptorDto source, FeatureGroupEntity target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setPartNumber(source.getPartNumber()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java new file mode 100644 index 0000000000..70f5666bcb --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupDescriptorDto; + +public class MapFeatureGroupEntityToFeatureGroupDescriptorDto + extends MappingBase { + @Override + public void doMapping(FeatureGroupEntity source, FeatureGroupDescriptorDto target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setPartNumber(source.getPartNumber()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity.java new file mode 100644 index 0000000000..f5ea8414d5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementDescriptorDto; + +public class MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity + extends MappingBase { + @Override + public void doMapping(LicenseAgreementDescriptorDto source, LicenseAgreementEntity target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setLicenseTerm(new MapChoiceOrOtherDtoToChoiceOrOther() + .applyMapping(source.getLicenseTerm(), ChoiceOrOther.class)); + target.setRequirementsAndConstrains(source.getRequirementsAndConstrains()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementEntityToLicenseAgreementDescriptorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementEntityToLicenseAgreementDescriptorDto.java new file mode 100644 index 0000000000..2fd4f669cf --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementEntityToLicenseAgreementDescriptorDto.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.ChoiceOrOtherDto; +import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementDescriptorDto; + +public class MapLicenseAgreementEntityToLicenseAgreementDescriptorDto + extends MappingBase { + @Override + public void doMapping(LicenseAgreementEntity source, LicenseAgreementDescriptorDto target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setLicenseTerm(new MapChoiceOrOtherToChoiceOrOtherDto() + .applyMapping(source.getLicenseTerm(), ChoiceOrOtherDto.class)); + target.setRequirementsAndConstrains(source.getRequirementsAndConstrains()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto.java new file mode 100644 index 0000000000..38384711b1 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.MultiChoiceOrOtherDto; + +public class MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto + extends MappingBase { + @Override + public void doMapping(LicenseKeyGroupEntity source, LicenseKeyGroupEntityDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setType(source.getType()); + target.setOperationalScope(new MapMultiChoiceOrOtherToMultiChoiceOrOtherDto() + .applyMapping(source.getOperationalScope(), MultiChoiceOrOtherDto.class)); + target.setReferencingFeatureGroups(source.getReferencingFeatureGroups()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity.java new file mode 100644 index 0000000000..aee27c8521 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; +import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupRequestDto; + +public class MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity + extends MappingBase { + @Override + public void doMapping(LicenseKeyGroupRequestDto source, LicenseKeyGroupEntity target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setType(source.getType()); + target.setOperationalScope(new MapMultiChoiceOrOtherDtoToMultiChoiceOrOther() + .applyMapping(source.getOperationalScope(), MultiChoiceOrOther.class)); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherDtoToMultiChoiceOrOther.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherDtoToMultiChoiceOrOther.java new file mode 100644 index 0000000000..320bf67bdf --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherDtoToMultiChoiceOrOther.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.MultiChoiceOrOtherDto; + +public class MapMultiChoiceOrOtherDtoToMultiChoiceOrOther + extends MappingBase { + + @Override + public void doMapping(MultiChoiceOrOtherDto source, MultiChoiceOrOther target) { + target.setChoices(source.getChoices()); + target.setOther(source.getOther()); + target.setResults(null); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherToMultiChoiceOrOtherDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherToMultiChoiceOrOtherDto.java new file mode 100644 index 0000000000..9649053fb4 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherToMultiChoiceOrOtherDto.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.MultiChoiceOrOtherDto; + +public class MapMultiChoiceOrOtherToMultiChoiceOrOtherDto + extends MappingBase { + + @Override + public void doMapping(MultiChoiceOrOther source, MultiChoiceOrOtherDto target) { + target.setChoices(source.getChoices()); + target.setOther(source.getOther()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity.java new file mode 100644 index 0000000000..1117a2db9f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelRequestDto; + + +public class MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity + extends MappingBase { + @Override + public void doMapping(VendorLicenseModelRequestDto source, VendorLicenseModelEntity target) { + target.setVendorName(source.getVendorName()); + target.setDescription(source.getDescription()); + target.setIconRef(source.getIconRef()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto.java new file mode 100644 index 0000000000..a53d5c9e36 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.core.utilities.CommonMethods; +import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; +import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionInfo; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto; + +import java.util.stream.Collectors; + +public class MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto + extends MappingBase { + @Override + public void doMapping(VersionedVendorLicenseModel source, VendorLicenseModelEntityDto target) { + VendorLicenseModelEntity sourceVlm = source.getVendorLicenseModel(); + target.setId(sourceVlm.getId()); + target.setVendorName(sourceVlm.getVendorName()); + target.setDescription(sourceVlm.getDescription()); + target.setIconRef(sourceVlm.getIconRef()); + + VersionInfo versionInfo = source.getVersionInfo(); + if (versionInfo != null) { + target.setVersion(versionInfo.getActiveVersion().toString()); + target.setStatus(versionInfo.getStatus()); + target.setLockingUser(versionInfo.getLockingUser()); + + if (!CommonMethods.isEmpty(versionInfo.getViewableVersions())) { + target.setViewableVersions(versionInfo.getViewableVersions().stream().map(Version::toString) + .collect(Collectors.toList())); + } + + if (!CommonMethods.isEmpty(versionInfo.getFinalVersions())) { + target.setFinalVersions(versionInfo.getFinalVersions().stream().map(Version::toString) + .collect(Collectors.toList())); + } + } + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java new file mode 100644 index 0000000000..ab9800e612 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java @@ -0,0 +1,157 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.services; + +import org.openecomp.sdc.vendorlicense.VendorLicenseManager; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; +import org.openecomp.sdc.versioning.dao.types.Version; + +import org.openecomp.sdcrests.vendorlicense.rest.EntitlementPools; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapEntitlementPoolEntityToEntitlementPoolEntityDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapEntitlementPoolRequestDtoToEntitlementPoolEntity; +import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolRequestDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.openecomp.sdcrests.wrappers.StringWrapperResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; + +@Named +@Service("entitlementPools") +@Scope(value = "prototype") +public class EntitlementPoolsImpl implements EntitlementPools { + + @Autowired + private VendorLicenseManager vendorLicenseManager; + + /** + * List entitlement pools response. + * + * @param vlmId the vlm id + * @param version the version + * @param user the user + * @return the response + */ + public Response listEntitlementPools(String vlmId, String version, String user) { + Collection entitlementPools = + vendorLicenseManager.listEntitlementPools(vlmId, Version.valueOf(version), user); + + GenericCollectionWrapper result = new GenericCollectionWrapper<>(); + MapEntitlementPoolEntityToEntitlementPoolEntityDto outputMapper = + new MapEntitlementPoolEntityToEntitlementPoolEntityDto(); + for (EntitlementPoolEntity ep : entitlementPools) { + result.add(outputMapper.applyMapping(ep, EntitlementPoolEntityDto.class)); + } + + return Response.ok(result).build(); + } + + /** + * Create entitlement pool response. + * + * @param request the request + * @param vlmId the vlm id + * @param user the user + * @return the response + */ + public Response createEntitlementPool(EntitlementPoolRequestDto request, String vlmId, + String user) { + EntitlementPoolEntity entitlementPoolEntity = + new MapEntitlementPoolRequestDtoToEntitlementPoolEntity() + .applyMapping(request, EntitlementPoolEntity.class); + entitlementPoolEntity.setVendorLicenseModelId(vlmId); + + EntitlementPoolEntity createdEntitlementPool = + vendorLicenseManager.createEntitlementPool(entitlementPoolEntity, user); + StringWrapperResponse result = + createdEntitlementPool != null ? new StringWrapperResponse(createdEntitlementPool.getId()) + : null; + + return Response.ok(result).build(); + } + + /** + * Update entitlement pool response. + * + * @param request the request + * @param vlmId the vlm id + * @param entitlementPoolId the entitlement pool id + * @param user the user + * @return the response + */ + public Response updateEntitlementPool(EntitlementPoolRequestDto request, String vlmId, + String entitlementPoolId, String user) { + EntitlementPoolEntity entitlementPoolEntity = + new MapEntitlementPoolRequestDtoToEntitlementPoolEntity() + .applyMapping(request, EntitlementPoolEntity.class); + + entitlementPoolEntity.setVendorLicenseModelId(vlmId); + entitlementPoolEntity.setId(entitlementPoolId); + + vendorLicenseManager.updateEntitlementPool(entitlementPoolEntity, user); + return Response.ok().build(); + } + + /** + * Gets entitlement pool. + * + * @param vlmId the vlm id + * @param version the version + * @param entitlementPoolId the entitlement pool id + * @param user the user + * @return the entitlement pool + */ + public Response getEntitlementPool(String vlmId, String version, String entitlementPoolId, + String user) { + EntitlementPoolEntity epInput = new EntitlementPoolEntity(); + epInput.setVendorLicenseModelId(vlmId); + epInput.setVersion(Version.valueOf(version)); + epInput.setId(entitlementPoolId); + EntitlementPoolEntity entitlementPool = vendorLicenseManager.getEntitlementPool(epInput, user); + + EntitlementPoolEntityDto entitlementPoolEntityDto = entitlementPool == null ? null : + new MapEntitlementPoolEntityToEntitlementPoolEntityDto() + .applyMapping(entitlementPool, EntitlementPoolEntityDto.class); + return Response.ok(entitlementPoolEntityDto).build(); + } + + /** + * Delete entitlement pool response. + * + * @param vlmId the vlm id + * @param entitlementPoolId the entitlement pool id + * @param user the user + * @return the response + */ + public Response deleteEntitlementPool(String vlmId, String entitlementPoolId, String user) { + EntitlementPoolEntity epInput = new EntitlementPoolEntity(); + epInput.setVendorLicenseModelId(vlmId); + epInput.setId(entitlementPoolId); + vendorLicenseManager.deleteEntitlementPool(epInput, user); + return Response.ok().build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java new file mode 100644 index 0000000000..daf35f9ee6 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java @@ -0,0 +1,169 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.services; + +import org.openecomp.core.utilities.CommonMethods; +import org.openecomp.sdc.vendorlicense.VendorLicenseManager; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; +import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; +import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorlicense.rest.FeatureGroups; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapEntitlementPoolEntityToEntitlementPoolEntityDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapFeatureGroupDescriptorDtoToFeatureGroupEntity; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapFeatureGroupEntityToFeatureGroupDescriptorDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupModelDto; +import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupRequestDto; +import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupUpdateRequestDto; +import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.openecomp.sdcrests.wrappers.StringWrapperResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import java.util.HashSet; +import javax.inject.Named; +import javax.ws.rs.core.Response; + + +@Named +@Service("featureGroups") +@Scope(value = "prototype") +public class FeatureGroupsImpl implements FeatureGroups { + + @Autowired + private VendorLicenseManager vendorLicenseManager; + + @Override + public Response listFeatureGroups(String vlmId, String version, String user) { + Collection featureGroupEntities = + vendorLicenseManager.listFeatureGroups(vlmId, Version.valueOf(version), user); + + MapFeatureGroupEntityToFeatureGroupDescriptorDto outputMapper = + new MapFeatureGroupEntityToFeatureGroupDescriptorDto(); + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + + for (FeatureGroupEntity fg : featureGroupEntities) { + FeatureGroupEntityDto fgDto = new FeatureGroupEntityDto(); + fgDto.setId(fg.getId()); + fgDto.setLicenseKeyGroupsIds(fg.getLicenseKeyGroupIds()); + fgDto.setEntitlementPoolsIds(fg.getEntitlementPoolIds()); + fgDto.setReferencingLicenseAgreements(fg.getReferencingLicenseAgreements()); + outputMapper.doMapping(fg, fgDto); + results.add(fgDto); + } + + return Response.ok(results).build(); + } + + @Override + public Response createFeatureGroup(FeatureGroupRequestDto request, String vlmId, String user) { + FeatureGroupEntity featureGroupEntity = new MapFeatureGroupDescriptorDtoToFeatureGroupEntity() + .applyMapping(request, FeatureGroupEntity.class); + featureGroupEntity.setVendorLicenseModelId(vlmId); + featureGroupEntity.setLicenseKeyGroupIds(request.getAddedLicenseKeyGroupsIds()); + featureGroupEntity.setEntitlementPoolIds(request.getAddedEntitlementPoolsIds()); + + FeatureGroupEntity createdFeatureGroup = + vendorLicenseManager.createFeatureGroup(featureGroupEntity, user); + + StringWrapperResponse result = + createdFeatureGroup != null ? new StringWrapperResponse(createdFeatureGroup.getId()) : null; + return Response.ok(result).build(); + } + + @Override + public Response updateFeatureGroup(FeatureGroupUpdateRequestDto request, String vlmId, + String featureGroupId, String user) { + FeatureGroupEntity featureGroupEntity = new MapFeatureGroupDescriptorDtoToFeatureGroupEntity() + .applyMapping(request, FeatureGroupEntity.class); + featureGroupEntity.setVendorLicenseModelId(vlmId); + featureGroupEntity.setId(featureGroupId); + + vendorLicenseManager + .updateFeatureGroup(featureGroupEntity, request.getAddedLicenseKeyGroupsIds(), + request.getRemovedLicenseKeyGroupsIds(), request.getAddedEntitlementPoolsIds(), + request.getRemovedEntitlementPoolsIds(), user); + return Response.ok().build(); + } + + @Override + public Response getFeatureGroup(String vlmId, String version, String featureGroupId, + String user) { + FeatureGroupEntity fgInput = new FeatureGroupEntity(); + fgInput.setVendorLicenseModelId(vlmId); + fgInput.setVersion(Version.valueOf(version)); + fgInput.setId(featureGroupId); + FeatureGroupModel featureGroupModel = vendorLicenseManager.getFeatureGroupModel(fgInput, user); + + if (featureGroupModel == null) { + return Response.ok().build(); + } + + FeatureGroupModelDto fgmDto = new FeatureGroupModelDto(); + fgmDto.setId(featureGroupModel.getFeatureGroup().getId()); + fgmDto.setReferencingLicenseAgreements( + featureGroupModel.getFeatureGroup().getReferencingLicenseAgreements()); + new MapFeatureGroupEntityToFeatureGroupDescriptorDto() + .doMapping(featureGroupModel.getFeatureGroup(), fgmDto); + + if (!CommonMethods.isEmpty(featureGroupModel.getLicenseKeyGroups())) { + fgmDto.setLicenseKeyGroups(new HashSet<>()); + + MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto lkgMapper = + new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto(); + for (LicenseKeyGroupEntity lkg : featureGroupModel.getLicenseKeyGroups()) { + fgmDto.getLicenseKeyGroups() + .add(lkgMapper.applyMapping(lkg, LicenseKeyGroupEntityDto.class)); + } + } + + if (!CommonMethods.isEmpty(featureGroupModel.getEntitlementPools())) { + fgmDto.setEntitlementPools(new HashSet<>()); + + MapEntitlementPoolEntityToEntitlementPoolEntityDto epMapper = + new MapEntitlementPoolEntityToEntitlementPoolEntityDto(); + for (EntitlementPoolEntity ep : featureGroupModel.getEntitlementPools()) { + fgmDto.getEntitlementPools().add(epMapper.applyMapping(ep, EntitlementPoolEntityDto.class)); + + } + } + + return Response.ok(fgmDto).build(); + } + + @Override + public Response deleteFeatureGroup(String vlmId, String featureGroupId, String user) { + FeatureGroupEntity fgInput = new FeatureGroupEntity(); + fgInput.setVendorLicenseModelId(vlmId); + fgInput.setId(featureGroupId); + vendorLicenseManager.deleteFeatureGroup(fgInput, user); + return Response.ok().build(); + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java new file mode 100644 index 0000000000..d87be05998 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java @@ -0,0 +1,186 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.services; + +import org.openecomp.core.utilities.CommonMethods; +import org.openecomp.sdc.vendorlicense.VendorLicenseManager; +import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementModel; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorlicense.rest.LicenseAgreements; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapFeatureGroupEntityToFeatureGroupDescriptorDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLicenseAgreementEntityToLicenseAgreementDescriptorDto; +import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementModelDto; +import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementRequestDto; +import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementUpdateRequestDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.openecomp.sdcrests.wrappers.StringWrapperResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import java.util.HashSet; +import javax.inject.Named; +import javax.ws.rs.core.Response; + +@Named +@Service("licenseAgreements") +@Scope(value = "prototype") +public class LicenseAgreementsImpl implements LicenseAgreements { + + @Autowired + private VendorLicenseManager vendorLicenseManager; + + /** + * List license agreements response. + * + * @param vlmId the vlm id + * @param version the version + * @param user the user + * @return the response + */ + public Response listLicenseAgreements(String vlmId, String version, String user) { + Collection licenseAgreements = + vendorLicenseManager.listLicenseAgreements(vlmId, Version.valueOf(version), user); + + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + MapLicenseAgreementEntityToLicenseAgreementDescriptorDto outputMapper = + new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto(); + for (LicenseAgreementEntity lae : licenseAgreements) { + LicenseAgreementEntityDto laeDto = new LicenseAgreementEntityDto(); + laeDto.setId(lae.getId()); + laeDto.setFeatureGroupsIds(lae.getFeatureGroupIds()); + outputMapper.doMapping(lae, laeDto); + results.add(laeDto); + } + + return Response.ok(results).build(); + } + + /** + * Create license agreement response. + * + * @param request the request + * @param vlmId the vlm id + * @param user the user + * @return the response + */ + public Response createLicenseAgreement(LicenseAgreementRequestDto request, String vlmId, + String user) { + LicenseAgreementEntity licenseAgreementEntity = + new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity() + .applyMapping(request, LicenseAgreementEntity.class); + licenseAgreementEntity.setVendorLicenseModelId(vlmId); + licenseAgreementEntity.setFeatureGroupIds(request.getAddedFeatureGroupsIds()); + + LicenseAgreementEntity createdLicenseAgreement = + vendorLicenseManager.createLicenseAgreement(licenseAgreementEntity, user); + StringWrapperResponse result = + createdLicenseAgreement != null ? new StringWrapperResponse(createdLicenseAgreement.getId()) + : null; + + return Response.ok(result).build(); + } + + /** + * Update license agreement response. + * + * @param request the request + * @param vlmId the vlm id + * @param licenseAgreementId the license agreement id + * @param user the user + * @return the response + */ + public Response updateLicenseAgreement(LicenseAgreementUpdateRequestDto request, String vlmId, + String licenseAgreementId, String user) { + LicenseAgreementEntity licenseAgreementEntity = + new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity() + .applyMapping(request, LicenseAgreementEntity.class); + licenseAgreementEntity.setVendorLicenseModelId(vlmId); + licenseAgreementEntity.setId(licenseAgreementId); + + vendorLicenseManager + .updateLicenseAgreement(licenseAgreementEntity, request.getAddedFeatureGroupsIds(), + request.getRemovedFeatureGroupsIds(), user); + return Response.ok().build(); + } + + /** + * Gets license agreement. + * + * @param vlmId the vlm id + * @param version the version + * @param licenseAgreementId the license agreement id + * @param user the user + * @return the license agreement + */ + public Response getLicenseAgreement(String vlmId, String version, String licenseAgreementId, + String user) { + LicenseAgreementModel licenseAgreementModel = vendorLicenseManager + .getLicenseAgreementModel(vlmId, Version.valueOf(version), licenseAgreementId, user); + + if (licenseAgreementModel == null) { + return Response.ok().build(); + } + + LicenseAgreementModelDto lamDto = new LicenseAgreementModelDto(); + lamDto.setId(licenseAgreementModel.getLicenseAgreement().getId()); + new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto() + .doMapping(licenseAgreementModel.getLicenseAgreement(), lamDto); + + if (!CommonMethods.isEmpty(licenseAgreementModel.getFeatureGroups())) { + lamDto.setFeatureGroups(new HashSet<>()); + + MapFeatureGroupEntityToFeatureGroupDescriptorDto fgMapper = + new MapFeatureGroupEntityToFeatureGroupDescriptorDto(); + for (FeatureGroupEntity fg : licenseAgreementModel.getFeatureGroups()) { + FeatureGroupEntityDto fgeDto = new FeatureGroupEntityDto(); + fgeDto.setId(fg.getId()); + fgeDto.setEntitlementPoolsIds(fg.getEntitlementPoolIds()); + fgeDto.setLicenseKeyGroupsIds(fg.getLicenseKeyGroupIds()); + fgMapper.doMapping(fg, fgeDto); + + lamDto.getFeatureGroups().add(fgeDto); + } + } + + return Response.ok(lamDto).build(); + } + + /** + * Delete license agreement response. + * + * @param vlmId the vlm id + * @param licenseAgreementId the license agreement id + * @param user the user + * @return the response + */ + public Response deleteLicenseAgreement(String vlmId, String licenseAgreementId, String user) { + vendorLicenseManager.deleteLicenseAgreement(vlmId, licenseAgreementId, user); + return Response.ok().build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java new file mode 100644 index 0000000000..6ef7e194b8 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java @@ -0,0 +1,159 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.services; + +import org.openecomp.sdc.vendorlicense.VendorLicenseManager; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; +import org.openecomp.sdc.versioning.dao.types.Version; + +import org.openecomp.sdcrests.vendorlicense.rest.LicenseKeyGroups; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity; +import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupRequestDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.openecomp.sdcrests.wrappers.StringWrapperResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; + +@Named +@Service("licenseKeyGroups") +@Scope(value = "prototype") +@Validated +public class LicenseKeyGroupsImpl implements LicenseKeyGroups { + + @Autowired + private VendorLicenseManager vendorLicenseManager; + + /** + * List license key groups response. + * + * @param vlmId the vlm id + * @param version the version + * @param user the user + * @return the response + */ + public Response listLicenseKeyGroups(String vlmId, String version, String user) { + Collection licenseKeyGroups = + vendorLicenseManager.listLicenseKeyGroups(vlmId, Version.valueOf(version), user); + + GenericCollectionWrapper result = new GenericCollectionWrapper<>(); + MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto outputMapper = + new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto(); + for (LicenseKeyGroupEntity ep : licenseKeyGroups) { + result.add(outputMapper.applyMapping(ep, LicenseKeyGroupEntityDto.class)); + } + + return Response.ok(result).build(); + } + + /** + * Create license key group response. + * + * @param request the request + * @param vlmId the vlm id + * @param user the user + * @return the response + */ + public Response createLicenseKeyGroup(LicenseKeyGroupRequestDto request, String vlmId, + String user) { + LicenseKeyGroupEntity licenseKeyGroupEntity = + new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity() + .applyMapping(request, LicenseKeyGroupEntity.class); + licenseKeyGroupEntity.setVendorLicenseModelId(vlmId); + + LicenseKeyGroupEntity createdLicenseKeyGroup = + vendorLicenseManager.createLicenseKeyGroup(licenseKeyGroupEntity, user); + StringWrapperResponse result = + createdLicenseKeyGroup != null ? new StringWrapperResponse(createdLicenseKeyGroup.getId()) + : null; + + return Response.ok(result).build(); + } + + /** + * Update license key group response. + * + * @param request the request + * @param vlmId the vlm id + * @param licenseKeyGroupId the license key group id + * @param user the user + * @return the response + */ + public Response updateLicenseKeyGroup(LicenseKeyGroupRequestDto request, String vlmId, + String licenseKeyGroupId, String user) { + LicenseKeyGroupEntity licenseKeyGroupEntity = + new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity() + .applyMapping(request, LicenseKeyGroupEntity.class); + + licenseKeyGroupEntity.setVendorLicenseModelId(vlmId); + licenseKeyGroupEntity.setId(licenseKeyGroupId); + + vendorLicenseManager.updateLicenseKeyGroup(licenseKeyGroupEntity, user); + return Response.ok().build(); + } + + /** + * Gets license key group. + * + * @param vlmId the vlm id + * @param version the version + * @param licenseKeyGroupId the license key group id + * @param user the user + * @return the license key group + */ + public Response getLicenseKeyGroup(String vlmId, String version, String licenseKeyGroupId, + String user) { + LicenseKeyGroupEntity lkgInput = new LicenseKeyGroupEntity(); + lkgInput.setVendorLicenseModelId(vlmId); + lkgInput.setVersion(Version.valueOf(version)); + lkgInput.setId(licenseKeyGroupId); + LicenseKeyGroupEntity licenseKeyGroup = vendorLicenseManager.getLicenseKeyGroup(lkgInput, user); + + LicenseKeyGroupEntityDto licenseKeyGroupEntityDto = licenseKeyGroup == null ? null : + new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto() + .applyMapping(licenseKeyGroup, LicenseKeyGroupEntityDto.class); + return Response.ok(licenseKeyGroupEntityDto).build(); + } + + /** + * Delete license key group response. + * + * @param vlmId the vlm id + * @param licenseKeyGroupId the license key group id + * @param user the user + * @return the response + */ + public Response deleteLicenseKeyGroup(String vlmId, String licenseKeyGroupId, String user) { + LicenseKeyGroupEntity lkgInput = new LicenseKeyGroupEntity(); + lkgInput.setVendorLicenseModelId(vlmId); + lkgInput.setId(licenseKeyGroupId); + vendorLicenseManager.deleteLicenseKeyGroup(lkgInput, user); + return Response.ok().build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java new file mode 100644 index 0000000000..c63da86e7a --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java @@ -0,0 +1,135 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.rest.services; + +import org.openecomp.sdc.vendorlicense.VendorLicenseManager; +import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; +import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorlicense.rest.VendorLicenseModels; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelActionRequestDto; +import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelRequestDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.openecomp.sdcrests.wrappers.StringWrapperResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; + + + +@Named +@Service("vendorLicenseModels") +@Scope(value = "prototype") +@Validated +public class VendorLicenseModelsImpl implements VendorLicenseModels { + + @Autowired + private VendorLicenseManager vendorLicenseManager; + + @Override + public Response listLicenseModels(String versionFilter, String user) { + Collection versionedVendorLicenseModels = + vendorLicenseManager.listVendorLicenseModels(versionFilter, user); + + GenericCollectionWrapper results = + new GenericCollectionWrapper<>(); + MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto outputMapper = + new MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto(); + for (VersionedVendorLicenseModel versionedVlm : versionedVendorLicenseModels) { + results.add(outputMapper.applyMapping(versionedVlm, VendorLicenseModelEntityDto.class)); + } + + return Response.ok(results).build(); + } + + @Override + public Response createLicenseModel(VendorLicenseModelRequestDto request, String user) { + VendorLicenseModelEntity vendorLicenseModelEntity = + new MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity() + .applyMapping(request, VendorLicenseModelEntity.class); + VendorLicenseModelEntity createdVendorLicenseModel = + vendorLicenseManager.createVendorLicenseModel(vendorLicenseModelEntity, user); + StringWrapperResponse result = createdVendorLicenseModel != null ? new StringWrapperResponse( + createdVendorLicenseModel.getId()) : null; + + return Response.ok(result).build(); + } + + @Override + public Response updateLicenseModel(VendorLicenseModelRequestDto request, String vlmId, + String user) { + VendorLicenseModelEntity vendorLicenseModelEntity = + new MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity() + .applyMapping(request, VendorLicenseModelEntity.class); + vendorLicenseModelEntity.setId(vlmId); + + vendorLicenseManager.updateVendorLicenseModel(vendorLicenseModelEntity, user); + return Response.ok().build(); + } + + @Override + public Response getLicenseModel(String vlmId, String version, String user) { + VersionedVendorLicenseModel versionedVlm = + vendorLicenseManager.getVendorLicenseModel(vlmId, Version.valueOf(version), user); + + VendorLicenseModelEntityDto vlmDto = versionedVlm == null ? null : + new MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto() + .applyMapping(versionedVlm, VendorLicenseModelEntityDto.class); + return Response.ok(vlmDto).build(); + } + + @Override + public Response deleteLicenseModel(String vlmId, String user) { + vendorLicenseManager.deleteVendorLicenseModel(vlmId, user); + return Response.ok().build(); + } + + @Override + public Response actOnLicenseModel(VendorLicenseModelActionRequestDto request, String vlmId, + String user) { + + switch (request.getAction()) { + case Checkout: + vendorLicenseManager.checkout(vlmId, user); + break; + case Undo_Checkout: + vendorLicenseManager.undoCheckout(vlmId, user); + break; + case Checkin: + vendorLicenseManager.checkin(vlmId, user); + break; + case Submit: + vendorLicenseManager.submit(vlmId, user); + break; + default: + } + + return Response.ok().build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml new file mode 100644 index 0000000000..1b0319dcf3 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml @@ -0,0 +1,30 @@ + + 4.0.0 + + + org.openecomp.sdc.onboarding + vendor-license-rest + 1.0.0-SNAPSHOT + ../ + + + vendor-license-rest-types + vendor-license-rest-types + + + + + + org.openecomp.sdc + openecomp-sdc-common-rest + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-vendor-license-manager + ${project.version} + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/ChoiceOrOtherDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/ChoiceOrOtherDto.java new file mode 100644 index 0000000000..ba8f57f79f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/ChoiceOrOtherDto.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + +import org.hibernate.validator.group.GroupSequenceProvider; +import org.openecomp.sdcrests.vendorlicense.types.validation.ChoiceOrOtherSequenceProvider; +import org.openecomp.sdcrests.vendorlicense.types.validation.OtherChoiceValidation; + +import javax.validation.constraints.NotNull; + +@GroupSequenceProvider(value = ChoiceOrOtherSequenceProvider.class) +public class ChoiceOrOtherDto> { + @NotNull + private E choice; + @NotNull(message = "may not be null when choice is set to 'Other'.", + groups = OtherChoiceValidation.class) + private String other; + + public E getChoice() { + return choice; + } + + public void setChoice(E choice) { + this.choice = choice; + } + + public String getOther() { + return other; + } + + public void setOther(String other) { + this.other = other; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + + ChoiceOrOtherDto that = (ChoiceOrOtherDto) obj; + + return choice != null ? choice.equals(that.choice) + : that.choice == null && (other != null ? other.equals(that.other) : that.other == null); + + } + + @Override + public int hashCode() { + int result = choice != null ? choice.hashCode() : 0; + result = 31 * result + (other != null ? other.hashCode() : 0); + return result; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolEntityDto.java new file mode 100644 index 0000000000..5ed40b00b7 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolEntityDto.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + + +import io.swagger.annotations.ApiModel; + +import java.util.Set; + +@ApiModel(value = "EntitlementPoolEntity") +public class EntitlementPoolEntityDto extends EntitlementPoolRequestDto { + private String id; + private Set referencingFeatureGroups; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Set getReferencingFeatureGroups() { + return referencingFeatureGroups; + } + + public void setReferencingFeatureGroups(Set referencingFeatureGroups) { + this.referencingFeatureGroups = referencingFeatureGroups; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolRequestDto.java new file mode 100644 index 0000000000..b70504e20e --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolRequestDto.java @@ -0,0 +1,144 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + +import io.swagger.annotations.ApiModel; +import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementMetric; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementTime; +import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope; +import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +@ApiModel(value = "EntitlementPoolRequest") +public class EntitlementPoolRequestDto { + + @NotNull + @Size(max = 120) + private String name; + @NotNull + @Size(max = 1000) + private String description; + @NotNull + private int thresholdValue; + @NotNull + private ThresholdUnit thresholdUnits; + @NotNull + @Valid + private ChoiceOrOtherDto entitlementMetric; + @Size(max = 120) + private String increments; + @NotNull + @Valid + private ChoiceOrOtherDto aggregationFunction; + @NotNull + @Valid + private MultiChoiceOrOtherDto operationalScope; + @NotNull + @Valid + private ChoiceOrOtherDto time; + @NotNull + @Size(max = 100) + private String manufacturerReferenceNumber; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getThresholdValue() { + return thresholdValue; + } + + public void setThresholdValue(int thresholdValue) { + this.thresholdValue = thresholdValue; + } + + public ThresholdUnit getThresholdUnits() { + return thresholdUnits; + } + + public void setThresholdUnits(ThresholdUnit thresholdUnits) { + this.thresholdUnits = thresholdUnits; + } + + public ChoiceOrOtherDto getEntitlementMetric() { + return entitlementMetric; + } + + public void setEntitlementMetric(ChoiceOrOtherDto entitlementMetric) { + this.entitlementMetric = entitlementMetric; + } + + public String getIncrements() { + return increments; + } + + public void setIncrements(String increments) { + this.increments = increments; + } + + public ChoiceOrOtherDto getAggregationFunction() { + return aggregationFunction; + } + + public void setAggregationFunction(ChoiceOrOtherDto aggregationFunction) { + this.aggregationFunction = aggregationFunction; + } + + public MultiChoiceOrOtherDto getOperationalScope() { + return operationalScope; + } + + public void setOperationalScope(MultiChoiceOrOtherDto operationalScope) { + this.operationalScope = operationalScope; + } + + public ChoiceOrOtherDto getTime() { + return time; + } + + public void setTime(ChoiceOrOtherDto time) { + this.time = time; + } + + public String getManufacturerReferenceNumber() { + return manufacturerReferenceNumber; + } + + public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) { + this.manufacturerReferenceNumber = manufacturerReferenceNumber; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupDescriptorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupDescriptorDto.java new file mode 100644 index 0000000000..5c1f8f2cfc --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupDescriptorDto.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +public class FeatureGroupDescriptorDto { + @NotNull + @Size(max = 120) + private String name; + @NotNull + @Size(max = 1000) + private String description; + @NotNull + private String partNumber; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getPartNumber() { + return partNumber; + } + + public void setPartNumber(String partNumber) { + this.partNumber = partNumber; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupEntityDto.java new file mode 100644 index 0000000000..a1d1edddcf --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupEntityDto.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + +import io.swagger.annotations.ApiModel; + +import java.util.Set; + +import javax.validation.constraints.Size; + + +@ApiModel(value = "FeatureGroupEntity") +public class FeatureGroupEntityDto extends FeatureGroupDescriptorDto { + private String id; + private Set licenseKeyGroupsIds; + @Size(min = 1) + private Set entitlementPoolsIds; + private Set referencingLicenseAgreements; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Set getLicenseKeyGroupsIds() { + return licenseKeyGroupsIds; + } + + public void setLicenseKeyGroupsIds(Set licenseKeyGroupsIds) { + this.licenseKeyGroupsIds = licenseKeyGroupsIds; + } + + public Set getEntitlementPoolsIds() { + return entitlementPoolsIds; + } + + public void setEntitlementPoolsIds(Set entitlementPoolsIds) { + this.entitlementPoolsIds = entitlementPoolsIds; + } + + public Set getReferencingLicenseAgreements() { + return referencingLicenseAgreements; + } + + public void setReferencingLicenseAgreements(Set referencingLicenseAgreements) { + this.referencingLicenseAgreements = referencingLicenseAgreements; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupModelDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupModelDto.java new file mode 100644 index 0000000000..1572320bb1 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupModelDto.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + +import io.swagger.annotations.ApiModel; + +import java.util.Collection; +import java.util.Set; + +@ApiModel(value = "FeatureGroupModel") +public class FeatureGroupModelDto extends FeatureGroupDescriptorDto { + private String id; + private Set referencingLicenseAgreements; + private Collection licenseKeyGroups; + private Collection entitlementPools; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Set getReferencingLicenseAgreements() { + return referencingLicenseAgreements; + } + + public void setReferencingLicenseAgreements(Set referencingLicenseAgreements) { + this.referencingLicenseAgreements = referencingLicenseAgreements; + } + + public Collection getLicenseKeyGroups() { + return licenseKeyGroups; + } + + public void setLicenseKeyGroups(Collection licenseKeyGroups) { + this.licenseKeyGroups = licenseKeyGroups; + } + + public Collection getEntitlementPools() { + return entitlementPools; + } + + public void setEntitlementPools(Collection entitlementPools) { + this.entitlementPools = entitlementPools; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupRequestDto.java new file mode 100644 index 0000000000..282e797f1b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupRequestDto.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + +import io.swagger.annotations.ApiModel; + +import java.util.Set; + +@ApiModel(value = "FeatureGroupRequest") +public class FeatureGroupRequestDto extends FeatureGroupDescriptorDto { + + private Set addedLicenseKeyGroupsIds; + private Set addedEntitlementPoolsIds; + + public Set getAddedLicenseKeyGroupsIds() { + return addedLicenseKeyGroupsIds; + } + + public void setAddedLicenseKeyGroupsIds(Set addedLicenseKeyGroupsIds) { + this.addedLicenseKeyGroupsIds = addedLicenseKeyGroupsIds; + } + + public Set getAddedEntitlementPoolsIds() { + return addedEntitlementPoolsIds; + } + + public void setAddedEntitlementPoolsIds(Set addedEntitlementPoolsIds) { + this.addedEntitlementPoolsIds = addedEntitlementPoolsIds; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupUpdateRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupUpdateRequestDto.java new file mode 100644 index 0000000000..002e48bb2c --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupUpdateRequestDto.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + +import io.swagger.annotations.ApiModel; + +import java.util.Set; + +@ApiModel(value = "FeatureGroupUpdateRequest") +public class FeatureGroupUpdateRequestDto extends FeatureGroupRequestDto { + + private Set removedLicenseKeyGroupsIds; + private Set removedEntitlementPoolsIds; + + public Set getRemovedLicenseKeyGroupsIds() { + return removedLicenseKeyGroupsIds; + } + + public void setRemovedLicenseKeyGroupsIds(Set removedLicenseKeyGroupsIds) { + this.removedLicenseKeyGroupsIds = removedLicenseKeyGroupsIds; + } + + public Set getRemovedEntitlementPoolsIds() { + return removedEntitlementPoolsIds; + } + + public void setRemovedEntitlementPoolsIds(Set removedEntitlementPoolsIds) { + this.removedEntitlementPoolsIds = removedEntitlementPoolsIds; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementDescriptorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementDescriptorDto.java new file mode 100644 index 0000000000..acfc130ed1 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementDescriptorDto.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + +import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +public class LicenseAgreementDescriptorDto { + + @NotNull + @Size(max = 120) + private String name; + @NotNull + @Size(max = 1000) + private String description; + @NotNull + @Valid + private ChoiceOrOtherDto licenseTerm; + @Size(max = 1000) + private String requirementsAndConstrains; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public ChoiceOrOtherDto getLicenseTerm() { + return licenseTerm; + } + + public void setLicenseTerm(ChoiceOrOtherDto licenseTerm) { + this.licenseTerm = licenseTerm; + } + + public String getRequirementsAndConstrains() { + return requirementsAndConstrains; + } + + public void setRequirementsAndConstrains(String requirementsAndConstrains) { + this.requirementsAndConstrains = requirementsAndConstrains; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementEntityDto.java new file mode 100644 index 0000000000..b0a8f65995 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementEntityDto.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + + +import io.swagger.annotations.ApiModel; + +import java.util.Set; +import javax.validation.constraints.Size; + + +@ApiModel(value = "LicenseAgreementEntity") +public class LicenseAgreementEntityDto extends LicenseAgreementDescriptorDto { + private String id; + @Size(min = 1) + private Set featureGroupsIds; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Set getFeatureGroupsIds() { + return featureGroupsIds; + } + + public void setFeatureGroupsIds(Set featureGroupsIds) { + this.featureGroupsIds = featureGroupsIds; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementModelDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementModelDto.java new file mode 100644 index 0000000000..a3460c321f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementModelDto.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + +import io.swagger.annotations.ApiModel; + +import java.util.Set; + +@ApiModel(value = "LicenseAgreementModel") +public class LicenseAgreementModelDto extends LicenseAgreementDescriptorDto { + private String id; + private Set featureGroups; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Set getFeatureGroups() { + return featureGroups; + } + + public void setFeatureGroups(Set featureGroups) { + this.featureGroups = featureGroups; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementRequestDto.java new file mode 100644 index 0000000000..3830bdb713 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementRequestDto.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + +import io.swagger.annotations.ApiModel; + +import java.util.Set; + +@ApiModel(value = "LicenseAgreementRequest") +public class LicenseAgreementRequestDto extends LicenseAgreementDescriptorDto { + + private Set addedFeatureGroupsIds; + + public Set getAddedFeatureGroupsIds() { + return addedFeatureGroupsIds; + } + + public void setAddedFeatureGroupsIds(Set addedFeatureGroupsIds) { + this.addedFeatureGroupsIds = addedFeatureGroupsIds; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementUpdateRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementUpdateRequestDto.java new file mode 100644 index 0000000000..2590bcf519 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementUpdateRequestDto.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + +import io.swagger.annotations.ApiModel; + +import java.util.Set; + +@ApiModel(value = "LicenseAgreementUpdateRequest") +public class LicenseAgreementUpdateRequestDto extends LicenseAgreementRequestDto { + private Set removedFeatureGroupsIds; + + public Set getRemovedFeatureGroupsIds() { + return removedFeatureGroupsIds; + } + + public void setRemovedFeatureGroupsIds(Set removedFeatureGroupsIds) { + this.removedFeatureGroupsIds = removedFeatureGroupsIds; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupEntityDto.java new file mode 100644 index 0000000000..9fab60fe27 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupEntityDto.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + + +import java.util.Set; + +public class LicenseKeyGroupEntityDto extends LicenseKeyGroupRequestDto { + private String id; + private Set referencingFeatureGroups; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Set getReferencingFeatureGroups() { + return referencingFeatureGroups; + } + + public void setReferencingFeatureGroups(Set referencingFeatureGroups) { + this.referencingFeatureGroups = referencingFeatureGroups; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupRequestDto.java new file mode 100644 index 0000000000..0df2e3251f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupRequestDto.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + +import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyType; +import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +public class LicenseKeyGroupRequestDto { + @NotNull + @Size(max = 120) + private String name; + @NotNull + @Size(max = 1000) + private String description; + @NotNull + private LicenseKeyType type; + @NotNull + @Valid + private MultiChoiceOrOtherDto operationalScope; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public LicenseKeyType getType() { + return type; + } + + public void setType(LicenseKeyType type) { + this.type = type; + } + + public MultiChoiceOrOtherDto getOperationalScope() { + return operationalScope; + } + + public void setOperationalScope(MultiChoiceOrOtherDto operationalScope) { + this.operationalScope = operationalScope; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/MultiChoiceOrOtherDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/MultiChoiceOrOtherDto.java new file mode 100644 index 0000000000..5a88e4c72f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/MultiChoiceOrOtherDto.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + +import org.hibernate.validator.group.GroupSequenceProvider; +import org.openecomp.sdcrests.vendorlicense.types.validation.MultiChoiceOrOtherSequenceProvider; +import org.openecomp.sdcrests.vendorlicense.types.validation.OtherChoiceValidation; + +import java.util.Set; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + + +@GroupSequenceProvider(value = MultiChoiceOrOtherSequenceProvider.class) +public class MultiChoiceOrOtherDto> { + @NotNull + @Size(min = 1, message = "must contain at least 1 choice.") + private Set choices; + @NotNull(message = "may not be null when choices is set to 'Other'.", + groups = OtherChoiceValidation.class) + private String other; + + public Set getChoices() { + return choices; + } + + public void setChoices(Set choices) { + this.choices = choices; + } + + public String getOther() { + return other; + } + + public void setOther(String other) { + this.other = other; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + + MultiChoiceOrOtherDto that = (MultiChoiceOrOtherDto) obj; + + return choices != null ? choices.equals(that.choices) + : that.choices == null && (other != null ? other.equals(that.other) : that.other == null); + + } + + @Override + public int hashCode() { + int result = choices != null ? choices.hashCode() : 0; + result = 31 * result + (other != null ? other.hashCode() : 0); + return result; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelActionRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelActionRequestDto.java new file mode 100644 index 0000000000..cfae94ce35 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelActionRequestDto.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + +import org.openecomp.sdcrests.versioning.types.VersioningAction; + +public class VendorLicenseModelActionRequestDto { + + private VersioningAction action; + + public VersioningAction getAction() { + return action; + } + + public void setAction(VersioningAction action) { + this.action = action; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelEntityDto.java new file mode 100644 index 0000000000..6c10f8fbe2 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelEntityDto.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + +import io.swagger.annotations.ApiModel; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; + + +import java.util.List; + +@ApiModel(value = "VendorLicenseModelEntity") +public class VendorLicenseModelEntityDto extends VendorLicenseModelRequestDto { + private String id; + private String version; + private VersionStatus status; + private String lockingUser; + private List viewableVersions; + private List finalVersions; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public VersionStatus getStatus() { + return status; + } + + public void setStatus(VersionStatus status) { + this.status = status; + } + + public String getLockingUser() { + return lockingUser; + } + + public void setLockingUser(String lockingUser) { + this.lockingUser = lockingUser; + } + + public List getViewableVersions() { + return viewableVersions; + } + + public void setViewableVersions(List viewableVersions) { + this.viewableVersions = viewableVersions; + } + + public List getFinalVersions() { + return finalVersions; + } + + public void setFinalVersions(List finalVersions) { + this.finalVersions = finalVersions; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelRequestDto.java new file mode 100644 index 0000000000..57b936a57f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelRequestDto.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types; + +import io.swagger.annotations.ApiModel; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +@ApiModel(value = "VendorLicenseModelRequest") +public class VendorLicenseModelRequestDto { + @NotNull + @Size(max = 25) + private String vendorName; + @NotNull + @Size(max = 1000) + private String description; + @NotNull + private String iconRef; + + public String getVendorName() { + return vendorName; + } + + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getIconRef() { + return iconRef; + } + + public void setIconRef(String iconRef) { + this.iconRef = iconRef; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/ChoiceOrOtherSequenceProvider.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/ChoiceOrOtherSequenceProvider.java new file mode 100644 index 0000000000..8be0ba3231 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/ChoiceOrOtherSequenceProvider.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types.validation; + +import org.hibernate.validator.spi.group.DefaultGroupSequenceProvider; +import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; +import org.openecomp.sdcrests.vendorlicense.types.ChoiceOrOtherDto; + +import java.util.ArrayList; +import java.util.List; + +public class ChoiceOrOtherSequenceProvider + implements DefaultGroupSequenceProvider { + + @Override + public List> getValidationGroups(ChoiceOrOtherDto choiceOrOther) { + List> sequence = new ArrayList<>(); + sequence.add(ChoiceOrOtherDto.class); + + if (choiceOrOther != null && choiceOrOther.getChoice() != null + && ChoiceOrOther.OTHER_ENUM_VALUE.equals(choiceOrOther.getChoice().name())) { + sequence.add(OtherChoiceValidation.class); + } + + return sequence; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/MultiChoiceOrOtherSequenceProvider.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/MultiChoiceOrOtherSequenceProvider.java new file mode 100644 index 0000000000..7cc9bbd2a2 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/MultiChoiceOrOtherSequenceProvider.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types.validation; + +import org.hibernate.validator.spi.group.DefaultGroupSequenceProvider; +import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther; +import org.openecomp.sdcrests.vendorlicense.types.MultiChoiceOrOtherDto; + +import java.util.ArrayList; +import java.util.List; + +public class MultiChoiceOrOtherSequenceProvider + implements DefaultGroupSequenceProvider { + + @Override + public List> getValidationGroups(MultiChoiceOrOtherDto multiChoiceOrOther) { + List> sequence = new ArrayList<>(); + sequence.add(MultiChoiceOrOtherDto.class); + + if (multiChoiceOrOther != null && multiChoiceOrOther.getChoices() != null + && multiChoiceOrOther.getChoices().size() == 1 + && MultiChoiceOrOther.OTHER_ENUM_VALUE + .equals((((Enum) (multiChoiceOrOther.getChoices().iterator().next())).name()))) { + sequence.add(OtherChoiceValidation.class); + } + + return sequence; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/OtherChoiceValidation.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/OtherChoiceValidation.java new file mode 100644 index 0000000000..ff682dd8b5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/OtherChoiceValidation.java @@ -0,0 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorlicense.types.validation; + +public interface OtherChoiceValidation { +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml new file mode 100644 index 0000000000..8bd67d6a07 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-rest-webapp + 1.0.0-SNAPSHOT + + + org.openecomp.sdc.onboarding + vendor-software-products-rest + vendor-software-products-rest + pom + + + + /vendor-software-products-rest-services + /vendor-software-products-rest-types + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml new file mode 100644 index 0000000000..7869edfa01 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml @@ -0,0 +1,144 @@ + + + 4.0.0 + + + org.openecomp.sdc.onboarding + vendor-software-products-rest + 1.0.0-SNAPSHOT + + + vendor-software-products-rest-services + + + + + org.springframework + spring-core + ${spring.framework.version} + + + org.springframework + spring-context + ${spring.framework.version} + + + org.springframework + spring-context-support + ${spring.framework.version} + + + org.springframework + spring-web + ${spring.framework.version} + + + org.springframework + spring-beans + ${spring.framework.version} + + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + ${cxf.version} + + + + org.apache.httpcomponents + httpclient + ${http.client.version} + + + + javax.ws.rs + javax.ws.rs-api + ${ws.rs.version} + + + + + cglib + cglib-nodep + ${cglib.nodep.version} + runtime + + + + + javax.inject + javax.inject + ${javax.inject.version} + provided + + + javax.ws.rs + javax.ws.rs-api + ${ws.rs.version} + + + com.sun.jersey + jersey-core + 1.19.1 + + + javax.ws.rs + jsr311-api + + + + + io.swagger + swagger-annotations + 1.5.3 + + + org.openecomp.sdc.onboarding + vendor-software-products-rest-types + ${project.version} + + + com.fasterxml.jackson.core + jackson-annotations + 2.7.4 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + 2.7.4 + + + org.codehaus.woodstox + woodstox-core-asl + 4.4.1 + + + + org.openecomp.sdc + openecomp-sdc-vendor-software-product-manager + ${project.version} + + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + test/core/unittest/offline/** + + true + + + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentProcesses.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentProcesses.java new file mode 100644 index 0000000000..3fae16cf7f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentProcesses.java @@ -0,0 +1,168 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +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.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/v1.0/vendor-software-products/{vspId}/components/{componentId}/processes") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor Software Product Component Processes") +@Validated +public interface ComponentProcesses { + @GET + @Path("/") + @ApiOperation(value = "List vendor software product component processes", + response = ProcessEntityDto.class, + responseContainer = "List") + Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @Pattern(regexp = Version.VERSION_REGEX, + message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") + String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @DELETE + @Path("/") + @ApiOperation(value = "Delete vendor software product processes", + responseContainer = "List") + Response deleteList( + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @POST + @Path("/") + @ApiOperation(value = "Create a vendor software product process") + Response create(@Valid ProcessRequestDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @GET + @Path("/{processId}") + @ApiOperation(value = "Get vendor software product process", + response = ProcessEntityDto.class) + Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @ApiParam(value = "Vendor software product process Id") @PathParam("processId") + String processId, + @Pattern(regexp = Version.VERSION_REGEX, + message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") + String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @DELETE + @Path("/{processId}") + @ApiOperation(value = "Delete vendor software product process") + Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @ApiParam(value = "Vendor software product process Id") @PathParam("processId") + String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @PUT + @Path("/{processId}") + @ApiOperation(value = "Update vendor software product process") + Response update(@Valid ProcessRequestDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @ApiParam(value = "Vendor software product process Id") @PathParam("processId") + String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @GET + @Path("/{processId}/upload") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @ApiOperation(value = "Get vendor software product process uploaded file") + Response getUploadedFile( + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @ApiParam(value = "Vendor software product process Id") @PathParam("processId") + String processId, + @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) + @QueryParam("version") String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @DELETE + @Path("/{processId}/upload") + @ApiOperation(value = "Delete vendor software product process uploaded file") + Response deleteUploadedFile( + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @ApiParam(value = "Vendor software product process Id") @PathParam("processId") + String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @POST + @Path("/{processId}/upload") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @ApiOperation(value = "Update vendor software product process upload") + Response uploadFile(@Multipart("upload") Attachment attachment, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") + String vspId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @ApiParam(value = "Vendor software product process Id") + @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentUploads.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentUploads.java new file mode 100644 index 0000000000..c7ad2f7fe5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentUploads.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.MibUploadStatusDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + + +@Path("/v1.0/vendor-software-products/{vspId}/components/{componentId}/monitors") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor Software Product Component MIB Uploads") +@Validated +public interface ComponentUploads { + @POST + @Path("/snmp-trap/upload") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @ApiOperation(value = "Upload vendor software product MIB Trap Definitions file") + Response uploadTrapMibFile(@Multipart("upload") Attachment attachment, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") + String vspId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_HEADER_PARAM) String user); + + @DELETE + @Path("/snmp-trap") + @ApiOperation(value = "Delete vendor software product MIB Trap Definitions file") + Response deleteTrapMibFile( + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @POST + @Path("/snmp/upload") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @ApiOperation(value = "Upload vendor software product MIB Poll Definitions file") + Response uploadPollMibFile(@Multipart("upload") Attachment attachment, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") + String vspId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_HEADER_PARAM) String user); + + @DELETE + @Path("/snmp") + @ApiOperation(value = "Delete vendor software product MIB Poll Definitions file") + Response deletePollMibFile( + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @GET + @Path("/snmp/") + @ApiOperation(value = "Get the filenames of uploaded MIB definitions", + response = MibUploadStatusDto.class) + Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Components.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Components.java new file mode 100644 index 0000000000..949a40cfbb --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Components.java @@ -0,0 +1,142 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +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.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/v1.0/vendor-software-products/{vspId}/components") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor Software Product Components") +@Validated +public interface Components { + @GET + @Path("/") + @ApiOperation(value = "List vendor software product components", + response = ComponentDto.class, + responseContainer = "List") + Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @Pattern(regexp = Version.VERSION_REGEX, + message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") + String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @DELETE + @Path("/") + @ApiOperation(value = "Delete vendor software product components", + responseContainer = "List") + Response deleteList( + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @POST + @Path("/") + @ApiOperation(value = "Create a vendor software product component") + Response create(@Valid ComponentRequestDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @GET + @Path("/{componentId}") + @ApiOperation(value = "Get vendor software product component", + response = ComponentData.class, + responseContainer = "CompositionEntityResponse") + Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @Pattern(regexp = Version.VERSION_REGEX, + message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") + String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @DELETE + @Path("/{componentId}") + @ApiOperation(value = "Delete vendor software product component") + Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @PUT + @Path("/{componentId}") + @ApiOperation(value = "Update vendor software product component") + Response update(@Valid ComponentRequestDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @GET + @Path("/{componentId}/questionnaire") + @ApiOperation(value = "Get vendor software product component questionnaire", + response = QuestionnaireResponseDto.class) + Response getQuestionnaire( + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) + @QueryParam("version") String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @PUT + @Path("/{componentId}/questionnaire") + @ApiOperation(value = "Update vendor software product component questionnaire") + Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") + String vspId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_HEADER_PARAM) String user); +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Networks.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Networks.java new file mode 100644 index 0000000000..5c7c9d7bd8 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Networks.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkRequestDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +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.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/v1.0/vendor-software-products/{vspId}/networks") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor Software Product Networks") +@Validated +public interface Networks { + @GET + @Path("/") + @ApiOperation(value = "List vendor software product networks", + response = NetworkDto.class, + responseContainer = "List") + Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @Pattern(regexp = Version.VERSION_REGEX, + message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") + String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @POST + @Path("/") + @ApiOperation(value = "Create a vendor software product network") + Response create(@Valid NetworkRequestDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @GET + @Path("/{networkId}") + @ApiOperation(value = "Get vendor software product network", + response = NetworkDto.class) + Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product network Id") @PathParam("networkId") + String networkId, + @Pattern(regexp = Version.VERSION_REGEX, + message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") + String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @DELETE + @Path("/{networkId}") + @ApiOperation(value = "Delete vendor software product network") + Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product network Id") @PathParam("networkId") + String networkId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @PUT + @Path("/{networkId}") + @ApiOperation(value = "Update vendor software product network") + Response update(@Valid NetworkRequestDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product network Id") @PathParam("networkId") + String networkId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Nics.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Nics.java new file mode 100644 index 0000000000..8cf26a405b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Nics.java @@ -0,0 +1,144 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +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.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/v1.0/vendor-software-products/{vspId}/components/{componentId}/nics") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor Software Product Component NICs") +@Validated +public interface Nics { + @GET + @Path("/") + @ApiOperation(value = "List vendor software product component NICs", + response = NicDto.class, + responseContainer = "List") + Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @Pattern(regexp = Version.VERSION_REGEX, + message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") + String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @POST + @Path("/") + @ApiOperation(value = "Create a vendor software product NIC") + Response create(@Valid NicRequestDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @GET + @Path("/{nicId}") + @ApiOperation(value = "Get vendor software product NIC", + response = NicDto.class) + Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @ApiParam(value = "Vendor software product NIC Id") @PathParam("nicId") String nicId, + @Pattern(regexp = Version.VERSION_REGEX, + message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") + String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @DELETE + @Path("/{nicId}") + @ApiOperation(value = "Delete vendor software product NIC") + Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @ApiParam(value = "Vendor software product NIC Id") @PathParam("nicId") + String nicId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @PUT + @Path("/{nicId}") + @ApiOperation(value = "Update vendor software product NIC") + Response update(@Valid NicRequestDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @ApiParam(value = "Vendor software product NIC Id") @PathParam("nicId") + String nicId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @GET + @Path("/{nicId}/questionnaire") + @ApiOperation(value = "Get vendor software product component NIC questionnaire", + response = QuestionnaireResponseDto.class) + Response getQuestionnaire( + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @ApiParam(value = "Vendor software product NIC Id") @PathParam("nicId") String nicId, + @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) + @QueryParam("version") String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @PUT + @Path("/{nicId}/questionnaire") + @ApiOperation(value = "Update vendor software product component NIC questionnaire") + Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") + String vspId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @ApiParam(value = "Vendor software product NIC Id") + @PathParam("nicId") String nicId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_HEADER_PARAM) String user); +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Processes.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Processes.java new file mode 100644 index 0000000000..b5c74587e4 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Processes.java @@ -0,0 +1,151 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto; + +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +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.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/v1.0/vendor-software-products/{vspId}/processes") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor Software Product Processes") +@Validated +public interface Processes { + @GET + @Path("/") + @ApiOperation(value = "List vendor software product processes", + response = ProcessEntityDto.class, + responseContainer = "List") + Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @Pattern(regexp = Version.VERSION_REGEX, + message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") + String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @DELETE + @Path("/") + @ApiOperation(value = "Delete vendor software product processes", + responseContainer = "List") + Response deleteList( + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @POST + @Path("/") + @ApiOperation(value = "Create a vendor software product process") + Response create(@Valid ProcessRequestDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @GET + @Path("/{processId}") + @ApiOperation(value = "Get vendor software product process", + response = ProcessEntityDto.class) + Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product process Id") @PathParam("processId") + String processId, + @Pattern(regexp = Version.VERSION_REGEX, + message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") + String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @DELETE + @Path("/{processId}") + @ApiOperation(value = "Delete vendor software product process") + Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product process Id") @PathParam("processId") + String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @PUT + @Path("/{processId}") + @ApiOperation(value = "Update vendor software product process") + Response update(@Valid ProcessRequestDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product process Id") @PathParam("processId") + String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @GET + @Path("/{processId}/upload") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @ApiOperation(value = "Get vendor software product process uploaded file") + Response getUploadedFile( + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product process Id") @PathParam("processId") + String processId, + @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) + @QueryParam("version") String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @DELETE + @Path("/{processId}/upload") + @ApiOperation(value = "Delete vendor software product process uploaded file") + Response deleteUploadedFile( + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product process Id") @PathParam("processId") + String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + + @POST + @Path("/{processId}/upload") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @ApiOperation(value = "Update vendor software product process upload") + Response uploadFile(@Multipart("upload") Attachment attachment, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") + String vspId, + @ApiParam(value = "Vendor software product process Id") + @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java new file mode 100644 index 0000000000..259ef723c6 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java @@ -0,0 +1,193 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; + +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; +import org.springframework.validation.annotation.Validated; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +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.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + + +@Path("/v1.0/vendor-software-products") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor Software Products") +@Validated +public interface VendorSoftwareProducts { + + @POST + @Path("/") + @ApiOperation(value = "Create a new vendor software product", + response = VspCreationDto.class) + Response createNewVsp(@Valid VspDescriptionDto vspDescriptionDto, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @GET + @Path("/") + @ApiOperation(value = "Get list of vendor software products and their description", + responseContainer = "List") + Response getVspList(@ApiParam( + value = "Currently supported values: 'Final' - only vendor software products with final " + + "version will be return - with their latest final version") + @QueryParam("versionFilter") String versionFilter, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @GET + @Path("/packages") + @ApiOperation(value = "Get list of translated CSAR files details", + response = PackageInfoDto.class, + responseContainer = "List") + Response listPackages(@ApiParam("Category") @QueryParam("category") String category, + @ApiParam("Sub-category") @QueryParam("subCategory") String subCategory, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @GET + @Path("/{vspId}") + @ApiOperation(value = "Get details of a vendor software product") + Response getVspDetails(@PathParam("vspId") String vspId, + @Pattern(regexp = Version.VERSION_REGEX, + message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") + String version, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_HEADER_PARAM) String user); + + @PUT + @Path("/{vspId}") + @ApiOperation(value = "Update an existing vendor software product") + Response updateVsp(@PathParam("vspId") String vspId, @Valid VspDescriptionDto vspDescriptionDto, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @DELETE + @Path("/{vspId}") + @ApiOperation(value = "Deletes vendor software product by given id") + Response deleteVsp(@PathParam("vspId") String vspId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @POST + @Path("{vspId}/upload") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @ApiOperation(value = "Uploads a HEAT package to translate", + response = UploadFileResponseDto.class) + Response uploadFile(@PathParam("vspId") String vspId, + @Multipart("upload") InputStream heatFileToUpload, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + String user); + + @GET + @Path("/{vspId}/downloadHeat") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @ApiOperation(value = "Get uploaded HEAT file", + notes = "Downloads the latest HEAT package", + response = File.class) + Response getLatestHeatPackage(@PathParam("vspId") String vspId, + /*@NotNull(message = USER_MISSING_ERROR_MSG)*/ + @HeaderParam(USER_HEADER_PARAM) String user); + + + @PUT + @Path("/{vspId}/actions") + @ApiOperation(value = "Actions on a vendor software product", + notes = "Performs one of the following actions on a vendor software product: |" + + "Checkout: Locks it for edits by other users. Only the locking user sees the edited " + + "version.|" + + "Undo_Checkout: Unlocks it and deletes the edits that were done.|" + + "Checkin: Unlocks it and activates the edited version to all users.| " + + "Submit: Finalize its active version.|" + + "Create_Package: Creates a CSAR zip file.|") + /*@ApiResponses(value = { + @ApiResponse(code = 200, message = "Action succeeded"), + @ApiResponse(code = 417, message = "Validation before submit has failed", + response = ValidationResponseDto.class)})*/ + Response actOnVendorSoftwareProduct(@PathParam("vspId") String vspId, + VersionSoftwareProductActionRequestDto request, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_HEADER_PARAM) String user) + throws IOException; + + @GET + @Path("/packages/{vspId}") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @ApiOperation(value = "Get translated CSAR file", + notes = "Exports translated file to a zip file", + response = File.class) + Response getTranslatedFile(@PathParam("vspId") String vspId, + @Pattern(regexp = Version.VERSION_REGEX, + message = Version.VERSION_STRING_VIOLATION_MSG) + @QueryParam("version") String version, + /*@NotNull(message = USER_MISSING_ERROR_MSG)*/ + @HeaderParam(USER_HEADER_PARAM) String user); + + @GET + @Path("/{vspId}/questionnaire") + @ApiOperation(value = "Get vendor software product questionnaire", + response = QuestionnaireResponseDto.class) + Response getQuestionnaire(@PathParam("vspId") String vspId, + @Pattern(regexp = Version.VERSION_REGEX, + message = Version.VERSION_STRING_VIOLATION_MSG) + @QueryParam("version") String version, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_HEADER_PARAM) String user); + + @PUT + @Path("/{vspId}/questionnaire") + @ApiOperation(value = "Update vendor software product questionnaire") + Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, + @PathParam("vspId") String vspId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_HEADER_PARAM) String user); +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDataToComponentDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDataToComponentDto.java new file mode 100644 index 0000000000..e448ed6ca7 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDataToComponentDto.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; + +public class MapComponentDataToComponentDto extends MappingBase { + @Override + public void doMapping(ComponentData source, ComponentDto target) { + target.setName(source.getName()); + target.setDisplayName( + source.getDisplayName() == null ? source.getName() : source.getDisplayName()); + target.setDescription(source.getDescription()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentDto.java new file mode 100644 index 0000000000..8878581d1c --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentDto.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; + +public class MapComponentEntityToComponentDto extends MappingBase { + @Override + public void doMapping(ComponentEntity source, ComponentDto target) { + target.setId(source.getId()); + ComponentData component = source.getComponentCompositionData(); + if (component != null) { + new MapComponentDataToComponentDto().doMapping(component, target); + } + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentRequestDtoToComponentEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentRequestDtoToComponentEntity.java new file mode 100644 index 0000000000..ce9e32770c --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentRequestDtoToComponentEntity.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRequestDto; + +public class MapComponentRequestDtoToComponentEntity + extends MappingBase { + @Override + public void doMapping(ComponentRequestDto source, ComponentEntity target) { + ComponentData component = new ComponentData(); + component.setName(source.getName()); + component.setDisplayName(source.getDisplayName()); + component.setDescription(source.getDescription()); + target.setComponentCompositionData(component); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityResponseToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityResponseToDto.java new file mode 100644 index 0000000000..b5b7ccdfee --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityResponseToDto.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionDataEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionDataEntityDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; + +public class MapCompositionEntityResponseToDto> + extends MappingBase, CompositionEntityResponseDto> { + private M dataMapper; + private Class targetDataClass; + + public MapCompositionEntityResponseToDto(M dataMapper, Class targetDataClass) { + this.dataMapper = dataMapper; + this.targetDataClass = targetDataClass; + } + + @Override + public void doMapping(CompositionEntityResponse source, + CompositionEntityResponseDto target) { + target.setId(source.getId()); + target.setSchema(source.getSchema()); + target.setData(dataMapper.applyMapping(source.getData(), targetDataClass)); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityValidationDataToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityValidationDataToDto.java new file mode 100644 index 0000000000..cb726dfc79 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityValidationDataToDto.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.apache.commons.collections4.CollectionUtils; +import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityValidationData; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; + +import java.util.stream.Collectors; + +public class MapCompositionEntityValidationDataToDto + extends MappingBase { + @Override + public void doMapping(CompositionEntityValidationData source, + CompositionEntityValidationDataDto target) { + target.setEntityType(source.getEntityType()); + target.setEntityId(source.getEntityId()); + target.setErrors(source.getErrors()); + if (CollectionUtils.isNotEmpty(source.getSubEntitiesValidationData())) { + target.setSubEntitiesValidationData(source.getSubEntitiesValidationData().stream() + .map(sub -> applyMapping(sub, CompositionEntityValidationDataDto.class)) + .collect(Collectors.toList())); + } + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapMibUploadStatusToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapMibUploadStatusToDto.java new file mode 100644 index 0000000000..d69e078ac1 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapMibUploadStatusToDto.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MibUploadStatus; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.MibUploadStatusDto; + +public class MapMibUploadStatusToDto extends MappingBase { + @Override + public void doMapping(MibUploadStatus source, MibUploadStatusDto target) { + target.setSnmpPoll(source.getSnmpPoll()); + target.setSnmpTrap(source.getSnmpTrap()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkEntityToNetworkDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkEntityToNetworkDto.java new file mode 100644 index 0000000000..1d79f35769 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkEntityToNetworkDto.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; + +public class MapNetworkEntityToNetworkDto extends MappingBase { + @Override + public void doMapping(NetworkEntity source, NetworkDto target) { + target.setId(source.getId()); + Network network = source.getNetworkCompositionData(); + if (network != null) { + new MapNetworkToNetworkDto().doMapping(network, target); + } + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkRequestDtoToNetworkEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkRequestDtoToNetworkEntity.java new file mode 100644 index 0000000000..00395c4b99 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkRequestDtoToNetworkEntity.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkRequestDto; + +public class MapNetworkRequestDtoToNetworkEntity + extends MappingBase { + @Override + public void doMapping(NetworkRequestDto source, NetworkEntity target) { + Network network = new Network(); + network.setName(source.getName()); + network.setDhcp(source.isDhcp()); + target.setNetworkCompositionData(network); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkToNetworkDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkToNetworkDto.java new file mode 100644 index 0000000000..dd819de1a6 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkToNetworkDto.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; + +public class MapNetworkToNetworkDto extends MappingBase { + @Override + public void doMapping(Network source, NetworkDto target) { + target.setName(source.getName()); + target.setDhcp(source.isDhcp()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicEntityToNicDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicEntityToNicDto.java new file mode 100644 index 0000000000..2af7e2ff6b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicEntityToNicDto.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto; + +public class MapNicEntityToNicDto extends MappingBase { + @Override + public void doMapping(NicEntity source, NicDto target) { + target.setId(source.getId()); + Nic nic = source.getNicCompositionData(); + if (nic != null) { + new MapNicToNicDto().doMapping(nic, target); + } + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicRequestDtoToNicEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicRequestDtoToNicEntity.java new file mode 100644 index 0000000000..4744364ea6 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicRequestDtoToNicEntity.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicRequestDto; + +public class MapNicRequestDtoToNicEntity extends MappingBase { + @Override + public void doMapping(NicRequestDto source, NicEntity target) { + Nic nic = new Nic(); + nic.setName(source.getName()); + nic.setDescription(source.getDescription()); + nic.setNetworkId(source.getNetworkId()); + target.setNicCompositionData(nic); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicToNicDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicToNicDto.java new file mode 100644 index 0000000000..2fcfd36b3f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicToNicDto.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto; + +public class MapNicToNicDto extends MappingBase { + @Override + public void doMapping(Nic source, NicDto target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setNetworkId(source.getNetworkId()); + target.setNetworkName(source.getNetworkName()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapPackageInfoToPackageInfoDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapPackageInfoToPackageInfoDto.java new file mode 100644 index 0000000000..9cd365480e --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapPackageInfoToPackageInfoDto.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto; + +public class MapPackageInfoToPackageInfoDto extends MappingBase { + @Override + public void doMapping(PackageInfo source, PackageInfoDto target) { + target.setDisplayName(source.getDisplayName()); + target.setVspName(source.getVspName()); + target.setPackageId(source.getVspId()); + target.setDescription(source.getVspDescription()); + target.setVersion(source.getVersion() == null ? null : source.getVersion().toString()); + target.setPackageType(source.getPackageType()); + target.setCategory(source.getCategory()); + target.setSubCategory(source.getSubCategory()); + target.setPackageChecksum(source.getPackageChecksum()); + target.setVendorRelease(source.getVendorRelease()); + target.setVendorName(source.getVendorName()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessEntityToProcessEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessEntityToProcessEntityDto.java new file mode 100644 index 0000000000..5842a30b70 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessEntityToProcessEntityDto.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto; + +public class MapProcessEntityToProcessEntityDto + extends MappingBase { + @Override + public void doMapping(ProcessEntity source, ProcessEntityDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setArtifactName(source.getArtifactName()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessRequestDtoToProcessEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessRequestDtoToProcessEntity.java new file mode 100644 index 0000000000..1fd35d1960 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessRequestDtoToProcessEntity.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto; + +public class MapProcessRequestDtoToProcessEntity + extends MappingBase { + @Override + public void doMapping(ProcessRequestDto source, ProcessEntity target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireResponseToQuestionnaireResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireResponseToQuestionnaireResponseDto.java new file mode 100644 index 0000000000..23fdf385e4 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireResponseToQuestionnaireResponseDto.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; + +public class MapQuestionnaireResponseToQuestionnaireResponseDto + extends MappingBase { + + @Override + public void doMapping(QuestionnaireResponse source, QuestionnaireResponseDto target) { + target.setData(source.getData()); + target.setSchema(source.getSchema()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapUploadFileResponseToUploadFileResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapUploadFileResponseToUploadFileResponseDto.java new file mode 100644 index 0000000000..29b6701413 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapUploadFileResponseToUploadFileResponseDto.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + + +import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; + +public class MapUploadFileResponseToUploadFileResponseDto + extends MappingBase { + @Override + public void doMapping(UploadFileResponse source, UploadFileResponseDto target) { + target.setStatus(source.getStatus()); + target.setErrors(source.getErrors()); + target.setFileNames(source.getFileNames()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapValidationResponseToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapValidationResponseToDto.java new file mode 100644 index 0000000000..68bc97d1a6 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapValidationResponseToDto.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireValidationResult; +import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse; +import org.openecomp.sdcrests.common.mapping.MapErrorCodeToDto; +import org.openecomp.sdcrests.common.mapping.MapErrorMessageToDto; +import org.openecomp.sdcrests.common.types.ErrorCodeDto; +import org.openecomp.sdcrests.common.types.ErrorMessageDto; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireValidationResultDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto; + + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class MapValidationResponseToDto + extends MappingBase { + private static Map> mapUploadDataErrors( + Map> uploadDataErrors) { + if (MapUtils.isEmpty(uploadDataErrors)) { + return null; + } + return uploadDataErrors.entrySet().stream().collect( + Collectors.toMap(entry -> entry.getKey(), entry -> mapErrorMessages(entry.getValue()))); + } + + private static QuestionnaireValidationResultDto mapQuestionnaireValidationResult( + QuestionnaireValidationResult questionnaireValidationResult) { + if (questionnaireValidationResult == null) { + return null; + } + QuestionnaireValidationResultDto questionnaireValidationResultDto = + new QuestionnaireValidationResultDto(); + questionnaireValidationResultDto.setValid(questionnaireValidationResult.isValid()); + questionnaireValidationResultDto.setValidationData(new MapCompositionEntityValidationDataToDto() + .applyMapping(questionnaireValidationResult.getValidationData(), + CompositionEntityValidationDataDto.class)); + return questionnaireValidationResultDto; + } + + private static List mapErrorMessages(List errorMessages) { + return errorMessages == null ? null : errorMessages.stream().map( + errorMessage -> new MapErrorMessageToDto() + .applyMapping(errorMessage, ErrorMessageDto.class)).collect(Collectors.toList()); + } + + private static Collection mapErrorCodes(Collection errorCodes) { + return CollectionUtils.isEmpty(errorCodes) ? null : errorCodes.stream() + .map(errorCode -> new MapErrorCodeToDto().applyMapping(errorCode, ErrorCodeDto.class)) + .collect(Collectors.toList()); + } + + @Override + public void doMapping(ValidationResponse source, ValidationResponseDto target) { + target.setValid(source.isValid()); + target.setVspErrors(mapErrorCodes(source.getVspErrors())); + target.setLicensingDataErrors(mapErrorCodes(source.getLicensingDataErrors())); + target.setUploadDataErrors(mapUploadDataErrors(source.getUploadDataErrors())); + target.setQuestionnaireValidationResult( + mapQuestionnaireValidationResult(source.getQuestionnaireValidationResult())); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java new file mode 100644 index 0000000000..9f03f7ff0d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.core.utilities.CommonMethods; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData; +import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; + +import java.util.stream.Collectors; + +public class MapVersionedVendorSoftwareProductInfoToVspDetailsDto + extends MappingBase { + + @Override + public void doMapping(VersionedVendorSoftwareProductInfo source, VspDetailsDto target) { + VspDetails vsp = source.getVspDetails(); + + target.setId(vsp.getId()); + target.setVersion(vsp.getVersion().toString()); + target.setName(vsp.getName()); + target.setDescription(vsp.getDescription()); + target.setCategory(vsp.getCategory()); + target.setSubCategory(vsp.getSubCategory()); + target.setVendorId(vsp.getVendorId()); + target.setVendorName(vsp.getVendorName()); + target.setLicensingVersion(vsp.getVlmVersion() == null ? null : vsp.getVlmVersion().toString()); + + if (vsp.getLicenseAgreement() != null || vsp.getFeatureGroups() != null) { + LicensingData licensingData = new LicensingData(); + licensingData.setLicenseAgreement(vsp.getLicenseAgreement()); + licensingData.setFeatureGroups(vsp.getFeatureGroups()); + target.setLicensingData(licensingData); + } + + target.setValidationData(vsp.getValidationDataStructure()); + + target.setStatus(source.getVersionInfo().getStatus()); + target.setLockingUser(source.getVersionInfo().getLockingUser()); + + if (!CommonMethods.isEmpty(source.getVersionInfo().getViewableVersions())) { + target.setViewableVersions( + source.getVersionInfo().getViewableVersions().stream().map(Version::toString) + .collect(Collectors.toList())); + } + + if (!CommonMethods.isEmpty(source.getVersionInfo().getFinalVersions())) { + target.setFinalVersions( + source.getVersionInfo().getFinalVersions().stream().map(Version::toString) + .collect(Collectors.toList())); + } + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java new file mode 100644 index 0000000000..77093fe682 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; + +import java.util.regex.Pattern; + +public class MapVspDescriptionDtoToVspDetails extends MappingBase { + + @Override + public void doMapping(VspDescriptionDto source, VspDetails target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setCategory(source.getCategory()); + target.setSubCategory(source.getSubCategory()); + target.setIcon(source.getIcon()); + target.setVendorName(source.getVendorName()); + target.setVendorId(source.getVendorId()); + + String vlmVersion = source.getLicensingVersion(); + if (vlmVersion != null) { + target.setVlmVersion( + Pattern.compile(Version.VERSION_REGEX).matcher(vlmVersion).find() ? Version + .valueOf(vlmVersion) : null); + } + + LicensingData licensingData = source.getLicensingData(); + if (licensingData != null) { + target.setLicenseAgreement(licensingData.getLicenseAgreement()); + target.setFeatureGroups(licensingData.getFeatureGroups()); + } + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MspVspDetailsToVspCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MspVspDetailsToVspCreationDto.java new file mode 100644 index 0000000000..a2de1741a3 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MspVspDetailsToVspCreationDto.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto; + +public class MspVspDetailsToVspCreationDto extends MappingBase { + @Override + public void doMapping(VspDetails source, VspCreationDto target) { + target.setVspId(source.getId()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java new file mode 100644 index 0000000000..2b16fea6c0 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java @@ -0,0 +1,144 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.services; + +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto; +import org.openecomp.sdcrests.vsp.rest.ComponentProcesses; +import org.openecomp.sdcrests.vsp.rest.mapping.MapProcessEntityToProcessEntityDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapProcessRequestDtoToProcessEntity; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.openecomp.sdcrests.wrappers.StringWrapperResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.io.File; +import java.io.InputStream; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; + + +@Named +@Service("componentProcesses") +@Scope(value = "prototype") +public class ComponentProcessesImpl implements ComponentProcesses { + @Autowired + private VendorSoftwareProductManager vendorSoftwareProductManager; + + @Override + public Response list(String vspId, String componentId, String version, String user) { + Collection processes = vendorSoftwareProductManager + .listProcesses(vspId, Version.valueOf(version), componentId, user); + + MapProcessEntityToProcessEntityDto mapper = new MapProcessEntityToProcessEntityDto(); + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + for (ProcessEntity process : processes) { + results.add(mapper.applyMapping(process, ProcessEntityDto.class)); + } + + return Response.ok(results).build(); + } + + @Override + public Response deleteList(String vspId, String componentId, String user) { + vendorSoftwareProductManager.deleteProcesses(vspId, componentId, user); + return Response.ok().build(); + } + + @Override + public Response create(ProcessRequestDto request, String vspId, String componentId, String user) { + ProcessEntity process = + new MapProcessRequestDtoToProcessEntity().applyMapping(request, ProcessEntity.class); + process.setVspId(vspId); + process.setComponentId(componentId); + + ProcessEntity createdProcess = vendorSoftwareProductManager.createProcess(process, user); + return Response + .ok(createdProcess != null ? new StringWrapperResponse(createdProcess.getId()) : null) + .build(); + } + + @Override + public Response get(String vspId, String componentId, String processId, String version, + String user) { + ProcessEntity process = vendorSoftwareProductManager + .getProcess(vspId, Version.valueOf(version), componentId, processId, user); + ProcessEntityDto result = + new MapProcessEntityToProcessEntityDto().applyMapping(process, ProcessEntityDto.class); + return Response.ok(result).build(); + } + + @Override + public Response delete(String vspId, String componentId, String processId, String user) { + vendorSoftwareProductManager.deleteProcess(vspId, componentId, processId, user); + return Response.ok().build(); + } + + @Override + public Response update(ProcessRequestDto request, String vspId, String componentId, + String processId, String user) { + ProcessEntity processEntity = + new MapProcessRequestDtoToProcessEntity().applyMapping(request, ProcessEntity.class); + processEntity.setVspId(vspId); + processEntity.setComponentId(componentId); + processEntity.setId(processId); + + vendorSoftwareProductManager.updateProcess(processEntity, user); + return Response.ok().build(); + } + + @Override + public Response getUploadedFile(String vspId, String componentId, String processId, + String version, String user) { + File file = vendorSoftwareProductManager + .getProcessArtifact(vspId, Version.valueOf(version), componentId, processId, user); + + Response.ResponseBuilder response = Response.ok(file); + if (file == null) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + response.header("Content-Disposition", "attachment; filename=" + file.getName()); + return response.build(); + } + + @Override + public Response deleteUploadedFile(String vspId, String componentId, String processId, + String user) { + vendorSoftwareProductManager.deleteProcessArtifact(vspId, componentId, processId, user); + return Response.ok().build(); + } + + @Override + public Response uploadFile(Attachment attachment, String vspId, String componentId, + String processId, String user) { + vendorSoftwareProductManager.uploadProcessArtifact(attachment.getObject(InputStream.class), + attachment.getContentDisposition().getParameter("filename"), vspId, componentId, processId, + user); + return Response.ok().build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentUploadsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentUploadsImpl.java new file mode 100644 index 0000000000..3cd384d7e7 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentUploadsImpl.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.services; + +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MibUploadStatus; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.MibUploadStatusDto; +import org.openecomp.sdcrests.vsp.rest.ComponentUploads; +import org.openecomp.sdcrests.vsp.rest.mapping.MapMibUploadStatusToDto; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import java.io.InputStream; +import javax.inject.Named; +import javax.ws.rs.core.Response; + +@Named +@Service("componentUploads") +@Scope(value = "prototype") +@Validated +public class ComponentUploadsImpl implements ComponentUploads { + @Autowired + private VendorSoftwareProductManager vendorSoftwareProductManager; + + @Override + public Response uploadTrapMibFile(Attachment attachment, String vspId, String componentId, + String user) { + vendorSoftwareProductManager.uploadComponentMib(attachment.getObject(InputStream.class), + attachment.getContentDisposition().getParameter("filename"), vspId, componentId, true, + user); + return Response.ok().build(); + } + + @Override + public Response deleteTrapMibFile(String vspId, String componentId, String user) { + vendorSoftwareProductManager.deleteComponentMib(vspId, componentId, true, user); + return Response.ok().build(); + } + + @Override + public Response uploadPollMibFile(Attachment attachment, String vspId, String componentId, + String user) { + vendorSoftwareProductManager.uploadComponentMib(attachment.getObject(InputStream.class), + attachment.getContentDisposition().getParameter("filename"), vspId, componentId, false, + user); + return Response.ok().build(); + } + + @Override + public Response deletePollMibFile(String vspId, String componentId, String user) { + vendorSoftwareProductManager.deleteComponentMib(vspId, componentId, false, user); + return Response.ok().build(); + } + + @Override + public Response list(String vspId, String componentId, String user) { + MibUploadStatus response = + vendorSoftwareProductManager.listMibFilenames(vspId, componentId, user); + + MibUploadStatusDto returnEntity = + new MapMibUploadStatusToDto().applyMapping(response, MibUploadStatusDto.class); + return Response.status(Response.Status.OK).entity(returnEntity).build(); + + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentsImpl.java new file mode 100644 index 0000000000..cba9abbdbc --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentsImpl.java @@ -0,0 +1,145 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.services; + +import org.apache.commons.collections4.CollectionUtils; +import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityValidationData; +import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; +import org.openecomp.sdcrests.vsp.rest.Components; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentDataToComponentDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentEntityToComponentDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentRequestDtoToComponentEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.openecomp.sdcrests.wrappers.StringWrapperResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; + + +@Named +@Service("components") +@Scope(value = "prototype") +public class ComponentsImpl implements Components { + @Autowired + private VendorSoftwareProductManager vendorSoftwareProductManager; + + @Override + public Response list(String vspId, String version, String user) { + Collection components = + vendorSoftwareProductManager.listComponents(vspId, Version.valueOf(version), user); + + MapComponentEntityToComponentDto mapper = new MapComponentEntityToComponentDto(); + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + for (ComponentEntity component : components) { + results.add(mapper.applyMapping(component, ComponentDto.class)); + } + + return Response.ok(results).build(); + } + + @Override + public Response deleteList(String vspId, String user) { + vendorSoftwareProductManager.deleteComponents(vspId, user); + return Response.ok().build(); + } + + @Override + public Response create(ComponentRequestDto request, String vspId, String user) { + ComponentEntity component = + new MapComponentRequestDtoToComponentEntity().applyMapping(request, ComponentEntity.class); + component.setVspId(vspId); + ComponentEntity createdComponent = + vendorSoftwareProductManager.createComponent(component, user); + return Response + .ok(createdComponent != null ? new StringWrapperResponse(createdComponent.getId()) : null) + .build(); + } + + @Override + public Response get(String vspId, String componentId, String version, String user) { + CompositionEntityResponse response = vendorSoftwareProductManager + .getComponent(vspId, Version.valueOf(version), componentId, user); + + CompositionEntityResponseDto responseDto = new CompositionEntityResponseDto<>(); + new MapCompositionEntityResponseToDto<>(new MapComponentDataToComponentDto(), + ComponentDto.class).doMapping(response, responseDto); + return Response.ok(responseDto).build(); + } + + @Override + public Response delete(String vspId, String componentId, String user) { + vendorSoftwareProductManager.deleteComponent(vspId, componentId, user); + return Response.ok().build(); + } + + @Override + public Response update(ComponentRequestDto request, String vspId, String componentId, + String user) { + ComponentEntity componentEntity = + new MapComponentRequestDtoToComponentEntity().applyMapping(request, ComponentEntity.class); + componentEntity.setVspId(vspId); + componentEntity.setId(componentId); + + CompositionEntityValidationData validationData = + vendorSoftwareProductManager.updateComponent(componentEntity, user); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) + ? Response.status(Response.Status.EXPECTATION_FAILED).entity( + new MapCompositionEntityValidationDataToDto() + .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : + Response.ok().build(); + } + + @Override + public Response getQuestionnaire(String vspId, String componentId, String version, String user) { + QuestionnaireResponse questionnaireResponse = vendorSoftwareProductManager + .getComponentQuestionnaire(vspId, Version.valueOf(version), componentId, user); + + QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); + return Response.ok(result).build(); + } + + @Override + public Response updateQuestionnaire(String questionnaireData, String vspId, String componentId, + String user) { + vendorSoftwareProductManager + .updateComponentQuestionnaire(vspId, componentId, questionnaireData, user); + return Response.ok().build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NetworksImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NetworksImpl.java new file mode 100644 index 0000000000..afc25ab4b0 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NetworksImpl.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.services; + +import org.apache.commons.collections4.CollectionUtils; +import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityValidationData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkRequestDto; +import org.openecomp.sdcrests.vsp.rest.Networks; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNetworkEntityToNetworkDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNetworkRequestDtoToNetworkEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNetworkToNetworkDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.openecomp.sdcrests.wrappers.StringWrapperResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; + + +@Named +@Service("networks") +@Scope(value = "prototype") +public class NetworksImpl implements Networks { + @Autowired + private VendorSoftwareProductManager vendorSoftwareProductManager; + + @Override + public Response list(String vspId, String version, String user) { + Collection networks = + vendorSoftwareProductManager.listNetworks(vspId, Version.valueOf(version), user); + + MapNetworkEntityToNetworkDto mapper = new MapNetworkEntityToNetworkDto(); + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + for (NetworkEntity network : networks) { + results.add(mapper.applyMapping(network, NetworkDto.class)); + } + + return Response.ok(results).build(); + } + + @Override + public Response create(NetworkRequestDto request, String vspId, String user) { + NetworkEntity network = + new MapNetworkRequestDtoToNetworkEntity().applyMapping(request, NetworkEntity.class); + network.setVspId(vspId); + NetworkEntity createdNetwork = vendorSoftwareProductManager.createNetwork(network, user); + return Response + .ok(createdNetwork != null ? new StringWrapperResponse(createdNetwork.getId()) : null) + .build(); + } + + @Override + public Response get(String vspId, String networkId, String version, String user) { + CompositionEntityResponse response = + vendorSoftwareProductManager.getNetwork(vspId, Version.valueOf(version), networkId, user); + + CompositionEntityResponseDto responseDto = new CompositionEntityResponseDto<>(); + new MapCompositionEntityResponseToDto<>(new MapNetworkToNetworkDto(), NetworkDto.class) + .doMapping(response, responseDto); + return Response.ok(responseDto).build(); + } + + @Override + public Response delete(String vspId, String networkId, String user) { + vendorSoftwareProductManager.deleteNetwork(vspId, networkId, user); + return Response.ok().build(); + } + + @Override + public Response update(NetworkRequestDto request, String vspId, String networkId, String user) { + NetworkEntity networkEntity = + new MapNetworkRequestDtoToNetworkEntity().applyMapping(request, NetworkEntity.class); + networkEntity.setVspId(vspId); + networkEntity.setId(networkId); + + CompositionEntityValidationData validationData = + vendorSoftwareProductManager.updateNetwork(networkEntity, user); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) + ? Response.status(Response.Status.EXPECTATION_FAILED).entity( + new MapCompositionEntityValidationDataToDto() + .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : + Response.ok().build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NicsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NicsImpl.java new file mode 100644 index 0000000000..ce601ec999 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NicsImpl.java @@ -0,0 +1,140 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.services; + +import org.apache.commons.collections4.CollectionUtils; +import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; +import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityValidationData; +import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; +import org.openecomp.sdc.versioning.dao.types.Version; + +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; +import org.openecomp.sdcrests.vsp.rest.Nics; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNicEntityToNicDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNicRequestDtoToNicEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNicToNicDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.openecomp.sdcrests.wrappers.StringWrapperResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; + + +@Named +@Service("nics") +@Scope(value = "prototype") +public class NicsImpl implements Nics { + @Autowired + private VendorSoftwareProductManager vendorSoftwareProductManager; + + @Override + public Response list(String vspId, String componentId, String version, String user) { + Collection nics = + vendorSoftwareProductManager.listNics(vspId, Version.valueOf(version), componentId, user); + + MapNicEntityToNicDto mapper = new MapNicEntityToNicDto(); + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + for (NicEntity nic : nics) { + results.add(mapper.applyMapping(nic, NicDto.class)); + } + + return Response.ok(results).build(); + } + + @Override + public Response create(NicRequestDto request, String vspId, String componentId, String user) { + NicEntity nic = new MapNicRequestDtoToNicEntity().applyMapping(request, NicEntity.class); + nic.setVspId(vspId); + nic.setComponentId(componentId); + + NicEntity createdNic = vendorSoftwareProductManager.createNic(nic, user); + return Response.ok(createdNic != null ? new StringWrapperResponse(createdNic.getId()) : null) + .build(); + } + + @Override + public Response get(String vspId, String componentId, String nicId, String version, String user) { + CompositionEntityResponse response = vendorSoftwareProductManager + .getNic(vspId, Version.valueOf(version), componentId, nicId, user); + + CompositionEntityResponseDto responseDto = new CompositionEntityResponseDto<>(); + new MapCompositionEntityResponseToDto<>(new MapNicToNicDto(), NicDto.class) + .doMapping(response, responseDto); + return Response.ok(responseDto).build(); + } + + @Override + public Response delete(String vspId, String componentId, String nicId, String user) { + vendorSoftwareProductManager.deleteNic(vspId, componentId, nicId, user); + return Response.ok().build(); + } + + @Override + public Response update(NicRequestDto request, String vspId, String componentId, String nicId, + String user) { + NicEntity nicEntity = new MapNicRequestDtoToNicEntity().applyMapping(request, NicEntity.class); + nicEntity.setVspId(vspId); + nicEntity.setComponentId(componentId); + nicEntity.setId(nicId); + + CompositionEntityValidationData validationData = + vendorSoftwareProductManager.updateNic(nicEntity, user); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) + ? Response.status(Response.Status.EXPECTATION_FAILED).entity( + new MapCompositionEntityValidationDataToDto() + .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : + Response.ok().build(); + } + + @Override + public Response getQuestionnaire(String vspId, String componentId, String nicId, String version, + String user) { + QuestionnaireResponse questionnaireResponse = vendorSoftwareProductManager + .getNicQuestionnaire(vspId, Version.valueOf(version), componentId, nicId, user); + + QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); + return Response.ok(result).build(); + } + + @Override + public Response updateQuestionnaire(String questionnaireData, String vspId, String componentId, + String nicId, String user) { + vendorSoftwareProductManager + .updateNicQuestionnaire(vspId, componentId, nicId, questionnaireData, user); + return Response.ok().build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ProcessesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ProcessesImpl.java new file mode 100644 index 0000000000..004d84591a --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ProcessesImpl.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.services; + +import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID; + +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto; +import org.openecomp.sdcrests.vsp.rest.ComponentProcesses; +import org.openecomp.sdcrests.vsp.rest.Processes; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import javax.inject.Named; +import javax.ws.rs.core.Response; + +@Named +@Service("processes") +@Scope(value = "prototype") +public class ProcessesImpl implements Processes { + + @Autowired + private ComponentProcesses componentProcesses; + + @Override + public Response list(String vspId, String version, String user) { + return componentProcesses.list(vspId, GENERAL_COMPONENT_ID, version, user); + } + + @Override + public Response deleteList(String vspId, String user) { + return componentProcesses.deleteList(vspId, GENERAL_COMPONENT_ID, user); + } + + @Override + public Response create(ProcessRequestDto request, String vspId, String user) { + return componentProcesses.create(request, vspId, GENERAL_COMPONENT_ID, user); + } + + @Override + public Response get(String vspId, String processId, String version, String user) { + return componentProcesses.get(vspId, GENERAL_COMPONENT_ID, processId, version, user); + } + + @Override + public Response delete(String vspId, String processId, String user) { + return componentProcesses.delete(vspId, GENERAL_COMPONENT_ID, processId, user); + } + + @Override + public Response update(ProcessRequestDto request, String vspId, String processId, String user) { + return componentProcesses.update(request, vspId, GENERAL_COMPONENT_ID, processId, user); + } + + @Override + public Response getUploadedFile(String vspId, String processId, String version, String user) { + return componentProcesses + .getUploadedFile(vspId, GENERAL_COMPONENT_ID, processId, version, user); + } + + @Override + public Response deleteUploadedFile(String vspId, String processId, String user) { + return componentProcesses.deleteUploadedFile(vspId, GENERAL_COMPONENT_ID, processId, user); + } + + @Override + public Response uploadFile(Attachment attachment, String vspId, String processId, String user) { + return componentProcesses.uploadFile(attachment, vspId, GENERAL_COMPONENT_ID, processId, user); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java new file mode 100644 index 0000000000..1c13f172f1 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java @@ -0,0 +1,228 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.services; + +import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; +import org.openecomp.sdcrests.vsp.rest.VendorSoftwareProducts; +import org.openecomp.sdcrests.vsp.rest.mapping.MapPackageInfoToPackageInfoDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapUploadFileResponseToUploadFileResponseDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapValidationResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapVersionedVendorSoftwareProductInfoToVspDetailsDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDescriptionDtoToVspDetails; +import org.openecomp.sdcrests.vsp.rest.mapping.MspVspDetailsToVspCreationDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import javax.inject.Named; +import javax.ws.rs.core.Response; + +@Named +@Service("vendorSoftwareProducts") +@Scope(value = "prototype") +public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { + + @Autowired + private VendorSoftwareProductManager vendorSoftwareProductManager; + + @Override + public Response createNewVsp(VspDescriptionDto vspDescriptionDto, String user) { + VspDetails vspDetails = + new MapVspDescriptionDtoToVspDetails().applyMapping(vspDescriptionDto, VspDetails.class); + + vspDetails = vendorSoftwareProductManager.createNewVsp(vspDetails, user); + + MspVspDetailsToVspCreationDto mapping = new MspVspDetailsToVspCreationDto(); + VspCreationDto vspCreationDto = mapping.applyMapping(vspDetails, VspCreationDto.class); + + return Response.ok(vspCreationDto).build(); + } + + @Override + public Response getVspList(String versionFilter, String user) { + List vspList = + vendorSoftwareProductManager.getVspList(versionFilter, user); + + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + if (!vspList.isEmpty()) { + MapVersionedVendorSoftwareProductInfoToVspDetailsDto mapper = + new MapVersionedVendorSoftwareProductInfoToVspDetailsDto(); + for (VersionedVendorSoftwareProductInfo versionedVsp : vspList) { + results.add(mapper.applyMapping(versionedVsp, VspDetailsDto.class)); + } + } + + return Response.ok(results).build(); + } + + @Override + public Response getVspDetails(String vspId, String version, String user) { + VersionedVendorSoftwareProductInfo vspDetails = + vendorSoftwareProductManager.getVspDetails(vspId, Version.valueOf(version), user); + + VspDetailsDto vspDetailsDto = vspDetails == null ? null + : new MapVersionedVendorSoftwareProductInfoToVspDetailsDto() + .applyMapping(vspDetails, VspDetailsDto.class); + + return Response.ok(vspDetailsDto).build(); + } + + @Override + public Response updateVsp(String vspId, VspDescriptionDto vspDescriptionDto, String user) { + VspDetails vspDetails = + new MapVspDescriptionDtoToVspDetails().applyMapping(vspDescriptionDto, VspDetails.class); + vspDetails.setId(vspId); + + vendorSoftwareProductManager.updateVsp(vspDetails, user); + + return Response.ok().build(); + } + + @Override + public Response deleteVsp(String vspId, String user) { + vendorSoftwareProductManager.deleteVsp(vspId, user); + + return Response.ok().build(); + } + + @Override + public Response actOnVendorSoftwareProduct(String vspId, + VersionSoftwareProductActionRequestDto request, + String user) throws IOException { + switch (request.getAction()) { + case Checkout: + vendorSoftwareProductManager.checkout(vspId, user); + break; + case Undo_Checkout: + vendorSoftwareProductManager.undoCheckout(vspId, user); + break; + case Checkin: + vendorSoftwareProductManager.checkin(vspId, user); + break; + case Submit: + ValidationResponse validationResponse = vendorSoftwareProductManager.submit(vspId, user); + if (!validationResponse.isValid()) { + return Response.status(Response.Status.EXPECTATION_FAILED).entity( + new MapValidationResponseToDto() + .applyMapping(validationResponse, ValidationResponseDto.class)).build(); + } + break; + case Create_Package: + PackageInfo packageInfo = vendorSoftwareProductManager.createPackage(vspId, user); + return Response.ok(packageInfo == null ? null + : new MapPackageInfoToPackageInfoDto().applyMapping(packageInfo, PackageInfoDto.class)) + .build(); + default: + } + + return Response.ok().build(); + } + + @Override + public Response uploadFile(String uploadVspId, InputStream heatFileToUpload, String user) { + UploadFileResponse uploadFileResponse = + vendorSoftwareProductManager.uploadFile(uploadVspId, heatFileToUpload, user); + + UploadFileResponseDto uploadFileResponseDto = new MapUploadFileResponseToUploadFileResponseDto() + .applyMapping(uploadFileResponse, UploadFileResponseDto.class); + + return Response.ok(uploadFileResponseDto).build(); + } + + @Override + public Response getLatestHeatPackage(String vspId, String user) { + File zipFile = vendorSoftwareProductManager.getLatestHeatPackage(vspId, user); + + if (zipFile == null) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + Response.ResponseBuilder response = Response.ok(zipFile); + response.header("Content-Disposition", "attachment; filename=" + zipFile.getName()); + return response.build(); + } + + @Override + public Response listPackages(String category, String subCategory, String user) { + List packageInfoList = + vendorSoftwareProductManager.listPackages(category, subCategory); + + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + MapPackageInfoToPackageInfoDto mapper = new MapPackageInfoToPackageInfoDto(); + + if (packageInfoList != null) { + for (PackageInfo packageInfo : packageInfoList) { + results.add(mapper.applyMapping(packageInfo, PackageInfoDto.class)); + } + } + return Response.ok(results).build(); + } + + @Override + public Response getTranslatedFile(String vspId, String version, String user) { + File zipFile = + vendorSoftwareProductManager.getTranslatedFile(vspId, Version.valueOf(version), user); + + Response.ResponseBuilder response = Response.ok(zipFile); + if (zipFile == null) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + response.header("Content-Disposition", "attachment; filename=" + zipFile.getName()); + return response.build(); + } + + @Override + public Response getQuestionnaire(String vspId, String version, String user) { + QuestionnaireResponse questionnaireResponse = + vendorSoftwareProductManager.getVspQuestionnaire(vspId, Version.valueOf(version), user); + + QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); + return Response.ok(result).build(); + } + + @Override + public Response updateQuestionnaire(String questionnaireData, String vspId, String user) { + vendorSoftwareProductManager.updateVspQuestionnaire(vspId, questionnaireData, user); + return Response.ok().build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml new file mode 100644 index 0000000000..d68c2b9034 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml @@ -0,0 +1,32 @@ + + + 4.0.0 + + + org.openecomp.sdc.onboarding + vendor-software-products-rest + 1.0.0-SNAPSHOT + ../ + + + vendor-software-products-rest-types + vendor-software-products-rest-types + + + + + + org.openecomp.sdc + openecomp-sdc-common-rest + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-vendor-software-product-manager + ${project.version} + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDto.java new file mode 100644 index 0000000000..63b7e6ea7d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDto.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class ComponentDto extends ComponentRequestDto implements CompositionDataEntityDto { + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentRequestDto.java new file mode 100644 index 0000000000..f626dab072 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentRequestDto.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class ComponentRequestDto { + + private String name; + private String displayName; + private String description; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionDataEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionDataEntityDto.java new file mode 100644 index 0000000000..8eb1c6557f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionDataEntityDto.java @@ -0,0 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public interface CompositionDataEntityDto { +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionEntityResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionEntityResponseDto.java new file mode 100644 index 0000000000..6e25e35d9b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionEntityResponseDto.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class CompositionEntityResponseDto { + private String id; + private String schema; + private T data; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getSchema() { + return schema; + } + + public void setSchema(String schema) { + this.schema = schema; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionEntityValidationDataDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionEntityValidationDataDto.java new file mode 100644 index 0000000000..20e07880c4 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionEntityValidationDataDto.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType; + +import java.util.Collection; + +public class CompositionEntityValidationDataDto { + private CompositionEntityType entityType; + private String entityId; + private Collection errors; + private Collection subEntitiesValidationData; + + public CompositionEntityType getEntityType() { + return entityType; + } + + public void setEntityType(CompositionEntityType entityType) { + this.entityType = entityType; + } + + public String getEntityId() { + return entityId; + } + + public void setEntityId(String entityId) { + this.entityId = entityId; + } + + public Collection getErrors() { + return errors; + } + + public void setErrors(Collection errors) { + this.errors = errors; + } + + public Collection getSubEntitiesValidationData() { + return subEntitiesValidationData; + } + + public void setSubEntitiesValidationData( + Collection subEntitiesValidationData) { + this.subEntitiesValidationData = subEntitiesValidationData; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/MibUploadStatusDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/MibUploadStatusDto.java new file mode 100644 index 0000000000..7331115c3f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/MibUploadStatusDto.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class MibUploadStatusDto { + private String snmpTrap; + private String snmpPoll; + + + public MibUploadStatusDto() { + } + + public String getSnmpTrap() { + return snmpTrap; + } + + public void setSnmpTrap(String snmpTrap) { + this.snmpTrap = snmpTrap; + } + + public String getSnmpPoll() { + return snmpPoll; + } + + public void setSnmpPoll(String snmpPoll) { + this.snmpPoll = snmpPoll; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NetworkDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NetworkDto.java new file mode 100644 index 0000000000..09ff449a52 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NetworkDto.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class NetworkDto extends NetworkRequestDto implements CompositionDataEntityDto { + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NetworkRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NetworkRequestDto.java new file mode 100644 index 0000000000..896ea22207 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NetworkRequestDto.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +import javax.validation.constraints.NotNull; + +public class NetworkRequestDto { + + @NotNull + private String name; + @NotNull + private boolean dhcp; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public boolean isDhcp() { + return dhcp; + } + + public void setDhcp(boolean dhcp) { + this.dhcp = dhcp; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicDto.java new file mode 100644 index 0000000000..05cd9a3a2b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicDto.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class NicDto extends NicRequestDto implements CompositionDataEntityDto { + + private String id; + private String networkName; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getNetworkName() { + return networkName; + } + + public void setNetworkName(String networkName) { + this.networkName = networkName; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicRequestDto.java new file mode 100644 index 0000000000..bd14012eee --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicRequestDto.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class NicRequestDto { + + private String name; + private String description; + private String networkId; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/PackageInfoDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/PackageInfoDto.java new file mode 100644 index 0000000000..5e689f3a0c --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/PackageInfoDto.java @@ -0,0 +1,124 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class PackageInfoDto { + + private String displayName; + private String description; + private String vspName; + private String version; + private String packageId; + private String category; + private String subCategory; + private String vendorName; + private String vendorRelease; + private String packageChecksum; + private String packageType; + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPackageId() { + return packageId; + } + + public void setPackageId(String packageId) { + this.packageId = packageId; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getSubCategory() { + return subCategory; + } + + public void setSubCategory(String subCategory) { + this.subCategory = subCategory; + } + + public String getVendorName() { + return vendorName; + } + + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + + public String getVendorRelease() { + return vendorRelease; + } + + public void setVendorRelease(String vendorRelease) { + this.vendorRelease = vendorRelease; + } + + public String getPackageChecksum() { + return packageChecksum; + } + + public void setPackageChecksum(String packageChecksum) { + this.packageChecksum = packageChecksum; + } + + public String getPackageType() { + return packageType; + } + + public void setPackageType(String packageType) { + this.packageType = packageType; + } + + public String getVspName() { + return vspName; + } + + public void setVspName(String vendorName) { + this.vspName = vendorName; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ProcessEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ProcessEntityDto.java new file mode 100644 index 0000000000..50923ff2e8 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ProcessEntityDto.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class ProcessEntityDto extends ProcessRequestDto { + private String id; + private String artifactName; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getArtifactName() { + return artifactName; + } + + public void setArtifactName(String artifactName) { + this.artifactName = artifactName; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ProcessRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ProcessRequestDto.java new file mode 100644 index 0000000000..e9c99b9d65 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ProcessRequestDto.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +import javax.validation.constraints.NotNull; + +public class ProcessRequestDto { + + @NotNull + private String name; + + private String description; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireResponseDto.java new file mode 100644 index 0000000000..81377764c2 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireResponseDto.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class QuestionnaireResponseDto { + private String schema; + private String data; + + public String getSchema() { + return schema; + } + + public void setSchema(String schema) { + this.schema = schema; + } + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireValidationResultDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireValidationResultDto.java new file mode 100644 index 0000000000..bf4805a9e1 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireValidationResultDto.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class QuestionnaireValidationResultDto { + private boolean valid; + private CompositionEntityValidationDataDto validationData; + + public boolean isValid() { + return valid; + } + + public void setValid(boolean valid) { + this.valid = valid; + } + + public CompositionEntityValidationDataDto getValidationData() { + return validationData; + } + + public void setValidationData(CompositionEntityValidationDataDto validationData) { + this.validationData = validationData; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/TranslatedFileDataDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/TranslatedFileDataDto.java new file mode 100644 index 0000000000..975f78d473 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/TranslatedFileDataDto.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class TranslatedFileDataDto { + + private String displayName; + private String version; + private String category; + private String subcategory; + private String vendorName; + private String vendorRelease; + private String packageChecksum; + private String packageType; + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getSubcategory() { + return subcategory; + } + + public void setSubcategory(String subcategory) { + this.subcategory = subcategory; + } + + public String getVandorName() { + return vendorName; + } + + public void setVandorName(String vandorName) { + this.vendorName = vandorName; + } + + public String getVendorRelease() { + return vendorRelease; + } + + public void setVendorRelease(String vendorRelease) { + this.vendorRelease = vendorRelease; + } + + public String getPackageChecksum() { + return packageChecksum; + } + + public void setPackageChecksum(String packageChecksum) { + this.packageChecksum = packageChecksum; + } + + public String getPackageType() { + return packageType; + } + + public void setPackageType(String packageType) { + this.packageType = packageType; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/UploadFileResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/UploadFileResponseDto.java new file mode 100644 index 0000000000..4f57b8031f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/UploadFileResponseDto.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileStatus; + + +import java.util.List; +import java.util.Map; + +public class UploadFileResponseDto { + private List fileNames; + private Map> errors; + private UploadFileStatus status; + + public Map> getErrors() { + return errors; + } + + public void setErrors(Map> errors) { + this.errors = errors; + } + + public UploadFileStatus getStatus() { + return status; + } + + public void setStatus(UploadFileStatus status) { + this.status = status; + } + + public List getFileNames() { + return fileNames; + } + + public void setFileNames(List fileNames) { + this.fileNames = fileNames; + } + + public void addNewFileToList(String filename) { + this.fileNames.add(filename); + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ValidationResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ValidationResponseDto.java new file mode 100644 index 0000000000..d76ae665ae --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ValidationResponseDto.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +import org.openecomp.sdcrests.common.types.ErrorCodeDto; +import org.openecomp.sdcrests.common.types.ErrorMessageDto; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +public class ValidationResponseDto { + private boolean valid; + private Collection vspErrors; + private Collection licensingDataErrors; + private Map> uploadDataErrors; + private QuestionnaireValidationResultDto questionnaireValidationResult; + + public boolean isValid() { + return valid; + } + + public void setValid(boolean valid) { + this.valid = valid; + } + + public Collection getVspErrors() { + return vspErrors; + } + + public void setVspErrors(Collection vspErrors) { + this.vspErrors = vspErrors; + } + + public Collection getLicensingDataErrors() { + return licensingDataErrors; + } + + public void setLicensingDataErrors(Collection licensingDataErrors) { + this.licensingDataErrors = licensingDataErrors; + } + + public Map> getUploadDataErrors() { + return uploadDataErrors; + } + + public void setUploadDataErrors(Map> uploadDataErrors) { + this.uploadDataErrors = uploadDataErrors; + } + + public QuestionnaireValidationResultDto getQuestionnaireValidationResult() { + return questionnaireValidationResult; + } + + public void setQuestionnaireValidationResult( + QuestionnaireValidationResultDto questionnaireValidationResult) { + this.questionnaireValidationResult = questionnaireValidationResult; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VendorSoftwareProductAction.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VendorSoftwareProductAction.java new file mode 100644 index 0000000000..c652c1cc4e --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VendorSoftwareProductAction.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public enum VendorSoftwareProductAction { + Checkout, + Undo_Checkout, + Checkin, + Submit, + Create_Package; +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VersionSoftwareProductActionRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VersionSoftwareProductActionRequestDto.java new file mode 100644 index 0000000000..4ce2bf92f4 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VersionSoftwareProductActionRequestDto.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class VersionSoftwareProductActionRequestDto { + private VendorSoftwareProductAction action; + + public VendorSoftwareProductAction getAction() { + return action; + } + + public void setAction(VendorSoftwareProductAction action) { + this.action = action; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java new file mode 100644 index 0000000000..d786017be1 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +public class VspCreationDto { + private String vspId; + + public String getVspId() { + return vspId; + } + + public void setVspId(String vspId) { + this.vspId = vspId; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java new file mode 100644 index 0000000000..a2358a0b48 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData; + +import javax.validation.constraints.NotNull; + +public class VspDescriptionDto { + @NotNull + private String name; + @NotNull + private String description; + private String icon; + @NotNull + private String category; + @NotNull + private String subCategory; + @NotNull + private String vendorName; + @NotNull + private String vendorId; // this will be populated with vlm id + private String licensingVersion; // this will be populated with vlm version + private LicensingData licensingData; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getIcon() { + return this.icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getSubCategory() { + return subCategory; + } + + public void setSubCategory(String subCategory) { + this.subCategory = subCategory; + } + + public String getVendorName() { + return vendorName; + } + + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + + public String getVendorId() { + return vendorId; + } + + public void setVendorId(String vendorId) { + this.vendorId = vendorId; + } + + public String getLicensingVersion() { + return licensingVersion; + } + + public void setLicensingVersion(String licensingVersion) { + this.licensingVersion = licensingVersion; + } + + public LicensingData getLicensingData() { + return licensingData; + } + + public void setLicensingData(LicensingData licensingData) { + this.licensingData = licensingData; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDetailsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDetailsDto.java new file mode 100644 index 0000000000..85b3203099 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDetailsDto.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +import io.swagger.annotations.ApiModel; + +import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; + +import java.util.List; + +@ApiModel(value = "VspDetails") +public class VspDetailsDto extends VspDescriptionDto { + + private String id; + private String version; + private List viewableVersions; + private List finalVersions; + private VersionStatus status; + private String lockingUser; + private ValidationStructureList validationData; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public List getViewableVersions() { + return viewableVersions; + } + + public void setViewableVersions(List viewableVersions) { + this.viewableVersions = viewableVersions; + } + + public List getFinalVersions() { + return finalVersions; + } + + public void setFinalVersions(List finalVersions) { + this.finalVersions = finalVersions; + } + + public VersionStatus getStatus() { + return status; + } + + public void setStatus(VersionStatus status) { + this.status = status; + } + + public String getLockingUser() { + return lockingUser; + } + + public void setLockingUser(String lockingUser) { + this.lockingUser = lockingUser; + } + + public ValidationStructureList getValidationData() { + return validationData; + } + + public void setValidationData(ValidationStructureList validationData) { + this.validationData = validationData; + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/CustomJsonValidator.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/CustomJsonValidator.java new file mode 100644 index 0000000000..23d90c02a2 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/CustomJsonValidator.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types.validation; + +import org.openecomp.core.utilities.json.JsonUtil; + +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; + +public class CustomJsonValidator implements ConstraintValidator { + + @Override + public void initialize(IsValidJson stringEnumeration) { + } + + + @Override + public boolean isValid(String json, ConstraintValidatorContext context) { + return JsonUtil.isValidJson(json); + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/IsValidJson.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/IsValidJson.java new file mode 100644 index 0000000000..7a9ec50721 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/IsValidJson.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types.validation; + + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import org.openecomp.sdcrests.common.RestConstants; + + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.validation.Constraint; +import javax.validation.Payload; + + +/** + * The interface Is valid json. + */ +@Documented +@Constraint(validatedBy = CustomJsonValidator.class) +@Target({METHOD, FIELD, ANNOTATION_TYPE, PARAMETER, CONSTRUCTOR}) +@Retention(RUNTIME) +public @interface IsValidJson { + /** + * The constant message. + */ + String message = RestConstants.INVALID_JSON_ERROR_MESSAGE; + + /** + * Message string. + * + * @return the string + */ + String message() default RestConstants.INVALID_JSON_ERROR_MESSAGE; + + /** + * Groups class [ ]. + * + * @return the class [ ] + */ + Class[] groups() default {}; + + /** + * Payload class [ ]. + * + * @return the class [ ] + */ + Class[] payload() default {}; +} + + -- cgit 1.2.3-korg