aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-03-22 15:33:06 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-03-24 06:59:47 +0000
commitd378c37fbd1ecec7b43394926f1ca32a695e07de (patch)
tree5c8a085f8732f980d871d966ac49361644efa698 /openecomp-be/backend
parenta6ae7294ecd336d7e88f915710b08e2658eaee00 (diff)
Reformat openecomp-be
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3449 Change-Id: I13e02322f8e00820cc5a1d85752caaeda9bf10d1
Diffstat (limited to 'openecomp-be/backend')
-rw-r--r--openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/ActionManager.java43
-rw-r--r--openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java673
-rw-r--r--openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManager.java8
-rw-r--r--openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManagerFactory.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImpl.java22
-rw-r--r--openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImpl.java31
-rw-r--r--openecomp-be/backend/openecomp-sdc-application-config-manager/src/main/java/org/openecomp/sdc/applicationconfig/ApplicationConfigManager.java14
-rw-r--r--openecomp-be/backend/openecomp-sdc-application-config-manager/src/main/java/org/openecomp/sdc/applicationconfig/impl/ApplicationConfigManagerImpl.java50
-rw-r--r--openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManager.java16
-rw-r--r--openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManagerFactory.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerFactoryImpl.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerImpl.java139
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDao.java11
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDaoFactory.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManager.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManagerFactory.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckResult.java14
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckStatus.java27
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthInfo.java14
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/MonitoredModules.java21
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/SiteMode.java18
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoFactoryImpl.java21
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoImpl.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerFactoryImpl.java9
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerImpl.java63
-rw-r--r--openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManager.java18
-rw-r--r--openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManagerFactory.java9
-rw-r--r--openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerFactoryImpl.java9
-rw-r--r--openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerImpl.java243
-rw-r--r--openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/AuthenticationCookie.java47
-rw-r--r--openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/AuthenticationCookieUtils.java32
-rw-r--r--openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/CipherUtil.java26
-rw-r--r--openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/CipherUtilException.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/ISessionValidationCookieConfiguration.java10
-rw-r--r--openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/ISessionValidationFilterConfiguration.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/Passwords.java319
-rw-r--r--openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/RepresentationUtils.java10
-rw-r--r--openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/FilterServletOutputStream.java16
-rw-r--r--openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/ResponceWrapper.java27
-rw-r--r--openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/SampleFilter.java97
-rw-r--r--openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/SessionValidationFilter.java165
-rw-r--r--openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/UploadValidationManager.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java111
-rw-r--r--openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/types/ValidationFileResponse.java20
-rw-r--r--openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/types/ValidationFileStatus.java8
-rw-r--r--openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java65
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java86
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManagerFactory.java14
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/errors/LimitErrorBuilder.java48
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerFactoryImpl.java35
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java1061
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManager.java19
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManagerFactory.java15
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java24
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManagerFactory.java7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/CompositionEntityDataManager.java50
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/CompositionEntityDataManagerFactory.java14
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java25
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManagerFactory.java7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java26
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManagerFactory.java15
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java28
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManagerFactory.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java9
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManagerFactory.java10
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManager.java15
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManagerFactory.java7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java21
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManagerFactory.java7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java16
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManagerFactory.java10
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java26
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManagerFactory.java7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java17
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VspManagerFactory.java10
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java81
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentErrorBuilder.java25
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CompositionEditNotAllowedErrorBuilder.java54
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComputeErrorBuilder.java6
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CreatePackageForNonFinalVendorSoftwareProductErrorBuilder.java52
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeleteNicErrorBuilder.java7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java59
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java36
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateNicInComponentErrorBuilder.java27
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/FileCreationErrorBuilder.java42
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java139
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/InformationArtifactCreationErrorBuilder.java31
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java59
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicErrorBuilder.java14
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java76
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicNetworkIdNotAllowedExternalNetworkErrorBuilder.java28
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java118
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java37
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OrchestrationTemplateNotFoundErrorBuilder.java39
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageInvalidErrorBuilder.java55
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageNotFoundErrorBuilder.java63
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java46
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/UploadInvalidErrorBuilder.java82
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java107
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/exception/OnboardPackageException.java1
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerFactoryImpl.java24
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java120
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerFactoryImpl.java20
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java339
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerFactoryImpl.java33
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerImpl.java864
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java22
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java427
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java21
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java404
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerFactoryImpl.java23
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java327
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java141
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java14
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java256
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerFactoryImpl.java17
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java130
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerFactoryImpl.java19
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java331
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java19
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java158
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerFactoryImpl.java15
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java330
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java314
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java48
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/ManifestAnalyzer.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageContentHandler.java18
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessor.java84
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/validation/CnfPackageValidator.java6
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java110
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java50
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java58
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java36
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java582
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/CsarSecurityValidator.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilder.java40
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidator.java43
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/PMDictionaryValidator.java14
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java121
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version3MetaDirectoryValidator.java7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version4MetaDirectoryValidator.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/Validator.java7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactory.java6
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/exception/MissingCertificateException.java1
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/FileExtractor.java3
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/InternalFilesFilter.java4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/ValidatorUtils.java11
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/exceptions/InvalidManifestMetadataException.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/exceptions/OrchestrationTemplateHandlerException.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java70
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java205
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessHandler.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java263
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/security/SecurityManager.java91
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResult.java34
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CompositionEntityResponse.java47
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ConfigConstants.java9
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResult.java33
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/LicensingData.java33
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ListComputeResponse.java36
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackage.java4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackageInfo.java14
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardSignedPackage.java6
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OrchestrationTemplateActionResponse.java145
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireResponse.java48
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireValidationResult.java33
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileResponse.java142
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStatus.java8
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStructure.java25
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java134
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MonitoringUploadStatus.java65
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/zusammen/ItemProperties.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTracker.java78
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java151
176 files changed, 5556 insertions, 7222 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/ActionManager.java b/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/ActionManager.java
index e5a1b6da43..4d4b02c787 100644
--- a/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/ActionManager.java
+++ b/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/ActionManager.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,50 +17,45 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.action;
-
+import java.util.List;
import org.openecomp.sdc.action.types.Action;
import org.openecomp.sdc.action.types.ActionArtifact;
import org.openecomp.sdc.action.types.OpenEcompComponent;
-import java.util.List;
-
/**
* Created by uttamp on 7/1/2016.
*/
-
public interface ActionManager {
- public Action createAction(Action action, String user);
- public Action updateAction(Action action, String user);
+ public Action createAction(Action action, String user);
- public void deleteAction(String actionInvariantUuId, String user);
+ public Action updateAction(Action action, String user);
- public List<Action> getFilteredActions(String filterType, String filterValue);
+ public void deleteAction(String actionInvariantUuId, String user);
- public List<OpenEcompComponent> getOpenEcompComponents();
+ public List<Action> getFilteredActions(String filterType, String filterValue);
- public List<Action> getActionsByActionInvariantUuId(String invariantId);
+ public List<OpenEcompComponent> getOpenEcompComponents();
- public Action getActionsByActionUuId(String actionUuId);
+ public List<Action> getActionsByActionInvariantUuId(String invariantId);
- public Action checkout(String invariantUuId, String user);
+ public Action getActionsByActionUuId(String actionUuId);
- public void undoCheckout(String invariantUuId, String user);
+ public Action checkout(String invariantUuId, String user);
- public Action checkin(String invariantUuId, String user);
+ public void undoCheckout(String invariantUuId, String user);
- public Action submit(String invariantUuId, String user);
+ public Action checkin(String invariantUuId, String user);
- public ActionArtifact uploadArtifact(ActionArtifact data, String actionInvariantUuId,
- String user);
+ public Action submit(String invariantUuId, String user);
- public ActionArtifact downloadArtifact(String actionUuId, String artifactUuId);
+ public ActionArtifact uploadArtifact(ActionArtifact data, String actionInvariantUuId, String user);
- public void deleteArtifact(String actionInvariantUuId, String artifactUuId, String user);
+ public ActionArtifact downloadArtifact(String actionUuId, String artifactUuId);
- public void updateArtifact(ActionArtifact data, String actionInvariantUuId, String user);
-}
+ public void deleteArtifact(String actionInvariantUuId, String artifactUuId, String user);
+ public void updateArtifact(ActionArtifact data, String actionInvariantUuId, String user);
+}
diff --git a/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java b/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java
index bc7a6f4f64..2cc42a85d3 100644
--- a/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java
@@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.action.impl;
+import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.COMPLETE;
+import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.ERROR;
import static org.openecomp.sdc.action.ActionConstants.ACTION_VERSIONABLE_TYPE;
import static org.openecomp.sdc.action.ActionConstants.ARTIFACT_METADATA_ATTR_NAME;
import static org.openecomp.sdc.action.ActionConstants.ARTIFACT_METADATA_ATTR_UUID;
@@ -63,6 +64,7 @@ import static org.openecomp.sdc.action.util.ActionUtil.actionLogPostProcessor;
import static org.openecomp.sdc.action.util.ActionUtil.actionLogPreProcessor;
import static org.openecomp.sdc.action.util.ActionUtil.getCurrentTimeStampUtc;
import static org.openecomp.sdc.versioning.dao.types.Version.VERSION_STRING_VIOLATION_MSG;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -88,7 +90,12 @@ import org.openecomp.sdc.action.dao.types.ActionArtifactEntity;
import org.openecomp.sdc.action.dao.types.ActionEntity;
import org.openecomp.sdc.action.errors.ActionErrorConstants;
import org.openecomp.sdc.action.errors.ActionException;
-import org.openecomp.sdc.action.types.*;
+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.ActionStatus;
+import org.openecomp.sdc.action.types.ActionSubOperation;
+import org.openecomp.sdc.action.types.OpenEcompComponent;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -105,20 +112,10 @@ import org.openecomp.sdc.versioning.types.VersionInfo;
import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.slf4j.MDC;
-import java.util.*;
-
-import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.COMPLETE;
-import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.ERROR;
-import static org.openecomp.sdc.action.ActionConstants.*;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.*;
-import static org.openecomp.sdc.action.util.ActionUtil.*;
-import static org.openecomp.sdc.versioning.dao.types.Version.VERSION_STRING_VIOLATION_MSG;
-
/**
* Manager Implementation for {@link ActionManager Action Library Operations}
* <br>
- * Handles Business layer validations and acts as an interface between the REST
- * and DAO layers.
+ * Handles Business layer validations and acts as an interface between the REST and DAO layers.
*/
public class ActionManagerImpl implements ActionManager {
@@ -131,94 +128,82 @@ public class ActionManagerImpl implements ActionManager {
private final ActionArtifactDao actionArtifactDao;
private final VersionInfoDao versionInfoDao;
private final UniqueValueDao uniqueValueDao;
+ private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
+
+ public ActionManagerImpl() {
+ actionDao = ActionDaoFactory.getInstance().createInterface();
+ versioningManager = ActionVersioningManagerFactory.getInstance().createInterface();
+ actionArtifactDao = ActionArtifactDaoFactory.getInstance().createInterface();
+ versionInfoDao = VersionInfoDaoFactory.getInstance().createInterface();
+ actionDao.registerVersioning(ACTION_VERSIONABLE_TYPE);
+ uniqueValueDao = UniqueValueDaoFactory.getInstance().createInterface();
+ }
- private final Logger log = LoggerFactory.getLogger(this.getClass()
- .getName());
-
- public ActionManagerImpl() {
- actionDao = ActionDaoFactory.getInstance().createInterface();
- versioningManager = ActionVersioningManagerFactory.getInstance().createInterface();
- actionArtifactDao = ActionArtifactDaoFactory.getInstance().createInterface();
- versionInfoDao = VersionInfoDaoFactory.getInstance().createInterface();
- actionDao.registerVersioning(ACTION_VERSIONABLE_TYPE);
- uniqueValueDao = UniqueValueDaoFactory.getInstance().createInterface();
- }
-
- public ActionManagerImpl(ActionDao actionDao, ActionVersioningManager versioningManager,
- ActionArtifactDao actionArtifactDao, VersionInfoDao versionInfoDao,
- UniqueValueDao uniqueValueDao) {
- this.actionDao = actionDao;
- this.versioningManager = versioningManager;
- this.actionArtifactDao = actionArtifactDao;
- this.versionInfoDao = versionInfoDao;
- this.uniqueValueDao = uniqueValueDao;
- }
- /**
- * List All Major, Last Minor and Candidate version (if any) for Given Action Invariant UUID
- *
- * @param invariantId Invariant UUID of the action for which the information is required
- * @return List of All Major, Last Minor and Candidate version if any Of {@link Action} with given
- * actionInvariantUuId.
- * @throws ActionException Exception with an action library specific code, short description and
- * detailed message for the error occurred during the operation
- */
+ public ActionManagerImpl(ActionDao actionDao, ActionVersioningManager versioningManager, ActionArtifactDao actionArtifactDao,
+ VersionInfoDao versionInfoDao, UniqueValueDao uniqueValueDao) {
+ this.actionDao = actionDao;
+ this.versioningManager = versioningManager;
+ this.actionArtifactDao = actionArtifactDao;
+ this.versionInfoDao = versionInfoDao;
+ this.uniqueValueDao = uniqueValueDao;
+ }
+ /**
+ * List All Major, Last Minor and Candidate version (if any) for Given Action Invariant UUID
+ *
+ * @param invariantId Invariant UUID of the action for which the information is required
+ * @return List of All Major, Last Minor and Candidate version if any Of {@link Action} with given actionInvariantUuId.
+ * @throws ActionException Exception with an action library specific code, short description and detailed message for the error occurred during
+ * the operation
+ */
@Override
public List<Action> getActionsByActionInvariantUuId(String invariantId) {
List<Action> actions;
-
log.debug(" entering getActionsByActionInvariantUuId with invariantID = " + invariantId);
actions = actionDao.getActionsByActionInvariantUuId(invariantId != null ? invariantId.toUpperCase() : null);
-
if (actions != null && actions.isEmpty()) {
throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
}
-
log.debug(" exit getActionsByActionInvariantUuId with invariantID = " + invariantId);
return actions;
}
/**
- * Get list of actions based on a filter criteria. If no filter is sent all
- * actions will be returned
+ * Get list of actions based on a filter criteria. If no filter is sent all actions will be returned
*
- * @param filterType
- * Filter by Vendor/Category/Model/Component/None
- * @param filterValue
- * Filter Parameter Value (Vendor ID/Category ID/Model
- * ID/Component ID)
- * @return List of {@link Action} objects based on a filter criteria <br>
- * Empty List if no records match the provided filter criteria
+ * @param filterType Filter by Vendor/Category/Model/Component/None
+ * @param filterValue Filter Parameter Value (Vendor ID/Category ID/Model ID/Component ID)
+ * @return List of {@link Action} objects based on a filter criteria <br> Empty List if no records match the provided filter criteria
*/
@Override
public List<Action> getFilteredActions(String filterType, String filterValue) {
List<Action> actions;
log.debug(" entering getFilteredActions By filterType = " + filterType + WITH_VALUE + filterValue);
switch (filterType) {
- case FILTER_TYPE_NONE:
- // Business validation for OPENECOMP Component type fetch (if any)
- break;
- case FILTER_TYPE_VENDOR:
- // Business validation for vendor type fetch (if any)
- break;
- case FILTER_TYPE_CATEGORY:
- // Business validation for Category type fetch (if any)
- break;
- case FILTER_TYPE_MODEL:
- // Business validation for model type fetch (if any)
- break;
- case FILTER_TYPE_OPEN_ECOMP_COMPONENT:
- // Business validation for OPENECOMP Component type fetch (if any)
- break;
- case FILTER_TYPE_NAME:
- actions = actionDao.getFilteredActions(filterType, filterValue != null ? filterValue.toLowerCase() : null);
- if (actions != null && actions.isEmpty()) {
- throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
- }
- log.debug(" exit getFilteredActions By filterType = " + filterType + WITH_VALUE + filterValue);
- return actions;
- default:
- break;
+ case FILTER_TYPE_NONE:
+ // Business validation for OPENECOMP Component type fetch (if any)
+ break;
+ case FILTER_TYPE_VENDOR:
+ // Business validation for vendor type fetch (if any)
+ break;
+ case FILTER_TYPE_CATEGORY:
+ // Business validation for Category type fetch (if any)
+ break;
+ case FILTER_TYPE_MODEL:
+ // Business validation for model type fetch (if any)
+ break;
+ case FILTER_TYPE_OPEN_ECOMP_COMPONENT:
+ // Business validation for OPENECOMP Component type fetch (if any)
+ break;
+ case FILTER_TYPE_NAME:
+ actions = actionDao.getFilteredActions(filterType, filterValue != null ? filterValue.toLowerCase() : null);
+ if (actions != null && actions.isEmpty()) {
+ throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
+ }
+ log.debug(" exit getFilteredActions By filterType = " + filterType + WITH_VALUE + filterValue);
+ return actions;
+ default:
+ break;
}
actions = actionDao.getFilteredActions(filterType, filterValue != null ? filterValue.toLowerCase() : null);
List<Action> majorMinorVersionList = getMajorMinorVersionActions(actions);
@@ -230,20 +215,16 @@ public class ActionManagerImpl implements ActionManager {
/**
* Get the properties of an action version by its UUID.
*
- * @param actionUuId
- * UUID of the specific action version
- * @return {@link Action} object corresponding the version represented by
- * the UUID
+ * @param actionUuId UUID of the specific action version
+ * @return {@link Action} object corresponding the version represented by the UUID
*/
@Override
public Action getActionsByActionUuId(String actionUuId) {
log.debug(" entering getActionsByActionUuId with actionUUID = " + actionUuId);
Action action = actionDao.getActionsByActionUuId(actionUuId != null ? actionUuId.toUpperCase() : null);
-
if (action == null) {
throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
}
-
log.debug(" exit getActionsByActionUuId with actionUUID = " + actionUuId);
return action;
}
@@ -251,9 +232,7 @@ public class ActionManagerImpl implements ActionManager {
/**
* List OPENECOMP Components supported by Action Library.
*
- * @return List of {@link OpenEcompComponent} objects supported by Action
- * Library <br>
- * Empty List if no components are found
+ * @return List of {@link OpenEcompComponent} objects supported by Action Library <br> Empty List if no components are found
*/
@Override
public List<OpenEcompComponent> getOpenEcompComponents() {
@@ -263,16 +242,13 @@ public class ActionManagerImpl implements ActionManager {
/**
* Delete an action.
*
- * @param actionInvariantUuId
- * Invariant UUID of the action to be deleted
- * @param user
- * User id of the user performing the operation
+ * @param actionInvariantUuId Invariant UUID of the action to be deleted
+ * @param user User id of the user performing the operation
*/
@Override
public void deleteAction(String actionInvariantUuId, String user) {
try {
- log.debug(
- "entering deleteAction with actionInvariantUuId = " + actionInvariantUuId + " and user = " + user);
+ log.debug("entering deleteAction with actionInvariantUuId = " + actionInvariantUuId + " and user = " + user);
actionLogPreProcessor(ActionSubOperation.DELETE_ACTION, TARGET_ENTITY_API);
versioningManager.delete(ACTION_VERSIONABLE_TYPE, actionInvariantUuId, user);
actionLogPostProcessor(COMPLETE);
@@ -286,10 +262,8 @@ public class ActionManagerImpl implements ActionManager {
/**
* Create a new Action.
*
- * @param action
- * Action object model of the user request for creating an action
- * @param user
- * AT&T id of the user sending the create request
+ * @param action Action object model of the user request for creating an action
+ * @param user AT&T id of the user sending the create request
* @return {@link Action} model object for the created action
*/
@Override
@@ -300,8 +274,7 @@ public class ActionManagerImpl implements ActionManager {
uniqueValueUtil.validateUniqueValue(ActionConstants.UniqueValues.ACTION_NAME, action.getName());
actionLogPostProcessor(COMPLETE);
} catch (CoreException exception) {
- String errorDesc = String.format(ACTION_ENTITY_UNIQUE_VALUE_MSG, ActionConstants.UniqueValues.ACTION_NAME,
- action.getName());
+ String errorDesc = String.format(ACTION_ENTITY_UNIQUE_VALUE_MSG, ActionConstants.UniqueValues.ACTION_NAME, action.getName());
log.error(errorDesc, exception);
actionLogPostProcessor(ERROR, ACTION_ENTITY_UNIQUE_VALUE_ERROR, errorDesc, false);
throw new ActionException(ACTION_ENTITY_UNIQUE_VALUE_ERROR, errorDesc);
@@ -312,55 +285,47 @@ public class ActionManagerImpl implements ActionManager {
action.setTimestamp(getCurrentTimeStampUtc());
action.setActionInvariantUuId(CommonMethods.nextUuId());
action.setActionUuId(CommonMethods.nextUuId());
-
actionLogPreProcessor(ActionSubOperation.CREATE_ACTION_VERSION, TARGET_ENTITY_API);
Version version = versioningManager.create(ACTION_VERSIONABLE_TYPE, action.getActionInvariantUuId(), user);
actionLogPostProcessor(COMPLETE);
log.metrics("");
-
action.setVersion(version.toString());
action.setStatus(ActionStatus.Locked);
action = updateData(action);
action = actionDao.createAction(action);
-
actionLogPreProcessor(ActionSubOperation.CREATE_ACTION_UNIQUE_VALUE, TARGET_ENTITY_API);
uniqueValueUtil.createUniqueValue(ActionConstants.UniqueValues.ACTION_NAME, action.getName());
actionLogPostProcessor(COMPLETE);
log.metrics("");
-
return action;
}
/**
* Update an existing action.
*
- * @param action
- * Action object model of the user request for creating an action
- * @param user
- * AT&T id of the user sending the update request
+ * @param action Action object model of the user request for creating an action
+ * @param user AT&T id of the user sending the update request
* @return {@link Action} model object for the update action
*/
@Override
public Action updateAction(Action action, String user) {
try {
- log.debug("entering updateAction to update action with invariantUuId = " + action.getActionInvariantUuId()
- + BY_USER + user);
+ log.debug("entering updateAction to update action with invariantUuId = " + action.getActionInvariantUuId() + BY_USER + user);
String invariantUuId = action.getActionInvariantUuId();
actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_API);
- VersionInfo versionInfo = versioningManager.getEntityVersionInfo(ACTION_VERSIONABLE_TYPE, invariantUuId,
- user, VersionableEntityAction.Write);
+ VersionInfo versionInfo = versioningManager
+ .getEntityVersionInfo(ACTION_VERSIONABLE_TYPE, invariantUuId, user, VersionableEntityAction.Write);
actionLogPostProcessor(COMPLETE);
log.metrics("");
-
Version activeVersion = versionInfo.getActiveVersion();
validateActions(action, activeVersion);
action.setStatus(ActionStatus.Locked); // Status will be Checkout
- // for update
+
+ // for update
updateData(action);
action.setUser(user);
action.setTimestamp(getCurrentTimeStampUtc());
actionDao.updateAction(action);
-
} catch (CoreException ce) {
formAndThrowException(ce);
}
@@ -371,10 +336,8 @@ public class ActionManagerImpl implements ActionManager {
/**
* Checkout an existing action.
*
- * @param invariantUuId
- * actionInvariantUuId of the action to be checked out
- * @param user
- * AT&T id of the user sending the checkout request
+ * @param invariantUuId actionInvariantUuId of the action to be checked out
+ * @param user AT&T id of the user sending the checkout request
* @return {@link Action} model object for the checkout action
*/
@Override
@@ -387,21 +350,15 @@ public class ActionManagerImpl implements ActionManager {
version = versioningManager.checkout(ACTION_VERSIONABLE_TYPE, invariantUuId, user);
actionLogPostProcessor(COMPLETE);
log.metrics("");
-
actionEntity = updateUniqueIdForVersion(invariantUuId, version, ActionStatus.Locked.name(), user);
} catch (CoreException exception) {
- if (exception.code() != null && exception.code()
- .id()
- .equals(VersioningErrorCodes.CHECKOT_ON_LOCKED_ENTITY)) {
+ if (exception.code() != null && exception.code().id().equals(VersioningErrorCodes.CHECKOT_ON_LOCKED_ENTITY)) {
actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
- VersionInfoEntity versionInfoEntity = versionInfoDao
- .get(new VersionInfoEntity(ACTION_VERSIONABLE_TYPE, invariantUuId));
+ VersionInfoEntity versionInfoEntity = versionInfoDao.get(new VersionInfoEntity(ACTION_VERSIONABLE_TYPE, invariantUuId));
actionLogPostProcessor(COMPLETE);
log.metrics("");
- String checkoutUser = versionInfoEntity.getCandidate()
- .getUser();
- log.debug("Actual checkout user for Action with invariantUUID= " + invariantUuId + " is = "
- + checkoutUser);
+ String checkoutUser = versionInfoEntity.getCandidate().getUser();
+ log.debug("Actual checkout user for Action with invariantUUID= " + invariantUuId + " is = " + checkoutUser);
if (!checkoutUser.equals(user)) {
throw new ActionException(ACTION_CHECKOUT_ON_LOCKED_ENTITY_OTHER_USER, exception.getMessage());
}
@@ -415,21 +372,17 @@ public class ActionManagerImpl implements ActionManager {
/**
* Undo an already checked out action.
*
- * @param invariantUuId
- * actionInvariantUuId of the checked out action
- * @param user
- * AT&T id of the user sending the request
+ * @param invariantUuId actionInvariantUuId of the checked out action
+ * @param user AT&T id of the user sending the request
*/
@Override
public void undoCheckout(String invariantUuId, String user) {
Version version;
try {
log.debug("entering undoCheckout for Action with invariantUUID= " + invariantUuId + BY_USER + user);
-
actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
// Get list of uploaded artifacts in this checked out version
- VersionInfoEntity versionInfoEntity = versionInfoDao
- .get(new VersionInfoEntity(ACTION_VERSIONABLE_TYPE, invariantUuId));
+ VersionInfoEntity versionInfoEntity = versionInfoDao.get(new VersionInfoEntity(ACTION_VERSIONABLE_TYPE, invariantUuId));
actionLogPostProcessor(COMPLETE);
log.metrics("");
if (versionInfoEntity == null) {
@@ -442,41 +395,35 @@ public class ActionManagerImpl implements ActionManager {
} else {
activeVersion = versionInfoEntity.getActiveVersion();
}
-
actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_VERSION, TARGET_ENTITY_DB);
- Action action = actionDao.get(new ActionEntity(invariantUuId, activeVersion))
- .toDto();
+ Action action = actionDao.get(new ActionEntity(invariantUuId, activeVersion)).toDto();
actionLogPostProcessor(COMPLETE);
log.metrics("");
-
// Perform undo checkout on the action
actionLogPreProcessor(ActionSubOperation.UNDO_CHECKOUT_ACTION, TARGET_ENTITY_API);
version = versioningManager.undoCheckout(ACTION_VERSIONABLE_TYPE, invariantUuId, user);
actionLogPostProcessor(COMPLETE);
log.metrics("");
-
if (version.equals(new Version(0, 0))) {
actionLogPreProcessor(ActionSubOperation.DELETE_UNIQUEVALUE, TARGET_ENTITY_API);
UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(uniqueValueDao);
uniqueValueUtil.deleteUniqueValue(ActionConstants.UniqueValues.ACTION_NAME, action.getName());
actionLogPostProcessor(COMPLETE);
log.metrics("");
-
actionLogPreProcessor(ActionSubOperation.DELETE_ACTIONVERSION, TARGET_ENTITY_DB);
// Added for the case where Create->Undo_Checkout->Checkout
+
// should not get the action
versionInfoDao.delete(new VersionInfoEntity(ACTION_VERSIONABLE_TYPE, invariantUuId));
actionLogPostProcessor(COMPLETE);
log.metrics("");
}
-
List<ActionArtifact> currentVersionArtifacts = action.getArtifacts();
-
// Delete the artifacts from action_artifact table (if any)
if (CollectionUtils.isNotEmpty(currentVersionArtifacts) && currentVersionArtifacts.size() > 0) {
for (ActionArtifact artifact : currentVersionArtifacts) {
ActionArtifactEntity artifactDeleteEntity = new ActionArtifactEntity(artifact.getArtifactUuId(),
- getEffectiveVersion(activeVersion.toString()));
+ getEffectiveVersion(activeVersion.toString()));
actionLogPreProcessor(ActionSubOperation.DELETE_ARTIFACT, TARGET_ENTITY_DB);
actionArtifactDao.delete(artifactDeleteEntity);
actionLogPostProcessor(COMPLETE);
@@ -492,10 +439,8 @@ public class ActionManagerImpl implements ActionManager {
/**
* Checkin a checked out action.
*
- * @param invariantUuId
- * actionInvariantUuId of the checked out action
- * @param user
- * AT&T id of the user sending the request
+ * @param invariantUuId actionInvariantUuId of the checked out action
+ * @param user AT&T id of the user sending the request
* @return {@link Action} model object for the updated action
*/
@Override
@@ -519,10 +464,8 @@ public class ActionManagerImpl implements ActionManager {
/**
* Submit a checked in action.
*
- * @param invariantUuId
- * actionInvariantUuId of the checked in action
- * @param user
- * AT&T id of the user sending the request
+ * @param invariantUuId actionInvariantUuId of the checked in action
+ * @param user AT&T id of the user sending the request
* @return {@link Action} model object for the updated action
*/
@Override
@@ -546,11 +489,8 @@ public class ActionManagerImpl implements ActionManager {
/**
* Download an artifact of an action.
*
- * @param artifactUuId
- * {@link ActionArtifact} object representing the artifact and
- * its metadata
- * @param actionUuId
- * UUID of the action for which the artifact has to be downloaded
+ * @param artifactUuId {@link ActionArtifact} object representing the artifact and its metadata
+ * @param actionUuId UUID of the action for which the artifact has to be downloaded
* @return downloaded action artifact object
*/
@Override
@@ -563,20 +503,17 @@ public class ActionManagerImpl implements ActionManager {
List<ActionArtifact> artifacts = action.getArtifacts();
String actionVersion = action.getVersion();
int effectiveVersion = getEffectiveVersion(actionVersion);
- ActionArtifact artifactMetadata = getArtifactMetadataFromAction(artifacts, ARTIFACT_METADATA_ATTR_UUID,
- artifactUuId);
+ ActionArtifact artifactMetadata = getArtifactMetadataFromAction(artifacts, ARTIFACT_METADATA_ATTR_UUID, artifactUuId);
if (artifactMetadata != null) {
String artifactName = artifactMetadata.getArtifactName();
actionArtifact = actionArtifactDao.downloadArtifact(effectiveVersion, artifactUuId);
actionArtifact.setArtifactName(artifactName);
-
} else {
throw new ActionException(ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE,
- ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST);
+ ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST);
}
} else {
- throw new ActionException(ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE,
- ActionErrorConstants.ACTION_ENTITY_NOT_EXIST);
+ throw new ActionException(ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE, ActionErrorConstants.ACTION_ENTITY_NOT_EXIST);
}
log.debug(" exit downloadArtifact with actionUUID= " + actionUuId + " and artifactUUID= " + artifactUuId);
return actionArtifact;
@@ -585,79 +522,62 @@ public class ActionManagerImpl implements ActionManager {
/**
* Upload an artifact to an action.
*
- * @param artifact
- * {@link ActionArtifact} object representing the artifact and
- * its metadata
- * @param actionInvariantUuId
- * Invariant UUID of the action to which the artifact has to be
- * uploaded
- * @param user
- * User ID of the user sending the request
+ * @param artifact {@link ActionArtifact} object representing the artifact and its metadata
+ * @param actionInvariantUuId Invariant UUID of the action to which the artifact has to be uploaded
+ * @param user User ID of the user sending the request
* @return Uploaded action artifact object
*/
@Override
public ActionArtifact uploadArtifact(ActionArtifact artifact, String actionInvariantUuId, String user) {
ActionArtifact uploadArtifactResponse = new ActionArtifact();
try {
- log.debug("entering uploadArtifact with actionInvariantUuId= " + actionInvariantUuId + "artifactName= "
- + artifact.getArtifactName());
+ log.debug("entering uploadArtifact with actionInvariantUuId= " + actionInvariantUuId + "artifactName= " + artifact.getArtifactName());
actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
- VersionInfo versionInfo = versioningManager.getEntityVersionInfo(ACTION_VERSIONABLE_TYPE,
- actionInvariantUuId, user, VersionableEntityAction.Write);
+ VersionInfo versionInfo = versioningManager
+ .getEntityVersionInfo(ACTION_VERSIONABLE_TYPE, actionInvariantUuId, user, VersionableEntityAction.Write);
actionLogPostProcessor(COMPLETE);
log.metrics("");
Version activeVersion = versionInfo.getActiveVersion();
actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONINVID, TARGET_ENTITY_DB);
- Action action = actionDao.get(new ActionEntity(actionInvariantUuId, activeVersion))
- .toDto();
+ Action action = actionDao.get(new ActionEntity(actionInvariantUuId, activeVersion)).toDto();
actionLogPostProcessor(COMPLETE);
log.metrics("");
String artifactUuId = generateActionArtifactUuId(action, artifact.getArtifactName());
// Check for Unique document name
List<ActionArtifact> actionArtifacts = action.getArtifacts();
- ActionArtifact artifactMetadata = getArtifactMetadataFromAction(actionArtifacts,
- ARTIFACT_METADATA_ATTR_NAME, artifact.getArtifactName());
+ ActionArtifact artifactMetadata = getArtifactMetadataFromAction(actionArtifacts, ARTIFACT_METADATA_ATTR_NAME, artifact.getArtifactName());
if (artifactMetadata != null) {
- throw new ActionException(ACTION_ARTIFACT_ALREADY_EXISTS_CODE,
- String.format(ACTION_ARTIFACT_ALREADY_EXISTS, actionInvariantUuId));
+ throw new ActionException(ACTION_ARTIFACT_ALREADY_EXISTS_CODE, String.format(ACTION_ARTIFACT_ALREADY_EXISTS, actionInvariantUuId));
}
-
// Create the artifact
artifact.setArtifactUuId(artifactUuId);
artifact.setTimestamp(getCurrentTimeStampUtc());
artifact.setEffectiveVersion(getEffectiveVersion(activeVersion.toString()));
actionArtifactDao.uploadArtifact(artifact);
-
// Update the action data field and timestamp
addArtifactMetadataInActionData(action, artifact);
-
// Set the response object
uploadArtifactResponse.setArtifactUuId(artifact.getArtifactUuId());
} catch (CoreException ce) {
formAndThrowException(ce);
}
- log.debug("exit uploadArtifact with actionInvariantUuId= " + actionInvariantUuId + "artifactName= "
- + artifact.getArtifactName());
+ log.debug("exit uploadArtifact with actionInvariantUuId= " + actionInvariantUuId + "artifactName= " + artifact.getArtifactName());
return uploadArtifactResponse;
}
@Override
public void deleteArtifact(String actionInvariantUuId, String artifactUuId, String user) {
- log.debug("enter deleteArtifact with actionInvariantUuId= " + actionInvariantUuId + ARTIFACT_UUID + artifactUuId
- + " and user = " + user);
+ log.debug("enter deleteArtifact with actionInvariantUuId= " + actionInvariantUuId + ARTIFACT_UUID + artifactUuId + " and user = " + user);
Action action = actionDao.getLockedAction(actionInvariantUuId, user);
List<ActionArtifact> actionArtifacts = action.getArtifacts();
- ActionArtifact artifactMetadata = getArtifactMetadataFromAction(actionArtifacts, ARTIFACT_METADATA_ATTR_UUID,
- artifactUuId);
+ ActionArtifact artifactMetadata = getArtifactMetadataFromAction(actionArtifacts, ARTIFACT_METADATA_ATTR_UUID, artifactUuId);
if (artifactMetadata == null) {
throw new ActionException(ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE,
- ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST);
+ ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST);
}
- if (artifactMetadata.getArtifactProtection()
- .equals(ActionArtifactProtection.readOnly.name())) {
+ if (artifactMetadata.getArtifactProtection().equals(ActionArtifactProtection.readOnly.name())) {
throw new ActionException(ACTION_ARTIFACT_DELETE_READ_ONLY, ACTION_ARTIFACT_DELETE_READ_ONLY_MSG);
} else {
-
// Update action by removing artifact metadata
String jsonData = action.getData();
List<ActionArtifact> artifacts = action.getArtifacts();// action.getArtifacts();
@@ -670,7 +590,6 @@ public class ActionManagerImpl implements ActionManager {
it.remove();
}
}
-
Map dataMap = JsonUtil.json2Object(jsonData, LinkedHashMap.class);
dataMap.put("artifacts", artifacts);
String data = JsonUtil.object2Json(dataMap);
@@ -681,66 +600,58 @@ public class ActionManagerImpl implements ActionManager {
actionLogPostProcessor(COMPLETE, null, "", false);
log.metrics("");
// delete Artifact if it's upload and delete action on same checkout
+
// version
String artifactName = artifactMetadata.getArtifactName();
String generatedArtifactUuId = generateActionArtifactUuId(action, artifactName);
if (generatedArtifactUuId.equals(artifactUuId)) {
if (artifact != null) {
ActionArtifactEntity artifactDeleteEntity = new ActionArtifactEntity(artifact.getArtifactUuId(),
- getEffectiveVersion(action.getVersion()));
+ getEffectiveVersion(action.getVersion()));
actionLogPreProcessor(ActionSubOperation.DELETE_ACTION_ARTIFACT, TARGET_ENTITY_DB);
actionArtifactDao.delete(artifactDeleteEntity);
}
actionLogPostProcessor(COMPLETE, null, "", false);
log.metrics("");
}
-
}
- log.debug("exit deleteArtifact with actionInvariantUuId= " + actionInvariantUuId + ARTIFACT_UUID + artifactUuId
- + " and user = " + user);
+ log.debug("exit deleteArtifact with actionInvariantUuId= " + actionInvariantUuId + ARTIFACT_UUID + artifactUuId + " and user = " + user);
}
/**
* Update an existing artifact.
*
- * @param artifact
- * {@link ActionArtifact} object representing the artifact and
- * its metadata
- * @param actionInvariantUuId
- * Invariant UUID of the action to which the artifact has to be
- * uploaded
- * @param user
- * User ID of the user sending the request
+ * @param artifact {@link ActionArtifact} object representing the artifact and its metadata
+ * @param actionInvariantUuId Invariant UUID of the action to which the artifact has to be uploaded
+ * @param user User ID of the user sending the request
*/
public void updateArtifact(ActionArtifact artifact, String actionInvariantUuId, String user) {
try {
- log.debug("Enter updateArtifact with actionInvariantUuId= " + actionInvariantUuId + ARTIFACT_UUID
- + artifact.getArtifactUuId() + " and user = " + user);
+ log.debug(
+ "Enter updateArtifact with actionInvariantUuId= " + actionInvariantUuId + ARTIFACT_UUID + artifact.getArtifactUuId() + " and user = "
+ + user);
actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_API);
- VersionInfo versionInfo = versioningManager.getEntityVersionInfo(ACTION_VERSIONABLE_TYPE,
- actionInvariantUuId, user, VersionableEntityAction.Write);
+ VersionInfo versionInfo = versioningManager
+ .getEntityVersionInfo(ACTION_VERSIONABLE_TYPE, actionInvariantUuId, user, VersionableEntityAction.Write);
actionLogPostProcessor(COMPLETE, null, "", false);
log.metrics("");
Version activeVersion = versionInfo.getActiveVersion();
actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONINVID, TARGET_ENTITY_DB);
- Action action = actionDao.get(new ActionEntity(actionInvariantUuId, activeVersion))
- .toDto();
+ Action action = actionDao.get(new ActionEntity(actionInvariantUuId, activeVersion)).toDto();
actionLogPostProcessor(COMPLETE, null, "", false);
log.metrics("");
List<ActionArtifact> actionArtifacts = action.getArtifacts();
- ActionArtifact artifactMetadataByUuId = getArtifactMetadataFromAction(actionArtifacts,
- ARTIFACT_METADATA_ATTR_UUID, artifact.getArtifactUuId());
+ ActionArtifact artifactMetadataByUuId = getArtifactMetadataFromAction(actionArtifacts, ARTIFACT_METADATA_ATTR_UUID,
+ artifact.getArtifactUuId());
// Check if artifact is already in action or not
if (artifactMetadataByUuId == null) {
throw new ActionException(ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE,
- ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST);
+ ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST);
}
// If user tries to change artifact name
- if (artifact.getArtifactName() != null && !artifactMetadataByUuId.getArtifactName()
- .equalsIgnoreCase(artifact.getArtifactName())) {
+ if (artifact.getArtifactName() != null && !artifactMetadataByUuId.getArtifactName().equalsIgnoreCase(artifact.getArtifactName())) {
throw new ActionException(ACTION_UPDATE_NOT_ALLOWED_CODE, ACTION_ARTIFACT_UPDATE_NAME_INVALID);
}
-
byte[] payload = artifact.getArtifact();
String artifactLabel = artifact.getArtifactLabel();
String artifactCategory = artifact.getArtifactCategory();
@@ -748,15 +659,12 @@ public class ActionManagerImpl implements ActionManager {
String artifactProtection = artifact.getArtifactProtection();
String artifactName = artifact.getArtifactName();
// If artifact read only
- if (artifactMetadataByUuId.getArtifactProtection()
- .equals(ActionArtifactProtection.readOnly.name())) {
- if (artifactName != null || artifactLabel != null || artifactCategory != null
- || artifactDescription != null || payload != null) {
+ if (artifactMetadataByUuId.getArtifactProtection().equals(ActionArtifactProtection.readOnly.name())) {
+ if (artifactName != null || artifactLabel != null || artifactCategory != null || artifactDescription != null || payload != null) {
throw new ActionException(ACTION_ARTIFACT_UPDATE_READ_ONLY, ACTION_ARTIFACT_UPDATE_READ_ONLY_MSG);
}
// Changing value from readOnly to readWrite
- if (artifactProtection != null
- && artifactProtection.equals(ActionArtifactProtection.readWrite.name())) {
+ if (artifactProtection != null && artifactProtection.equals(ActionArtifactProtection.readWrite.name())) {
artifactMetadataByUuId.setArtifactProtection(ActionArtifactProtection.readWrite.name());
artifactMetadataByUuId.setTimestamp(getCurrentTimeStampUtc());
updateArtifactMetadataInActionData(action, artifactMetadataByUuId);
@@ -777,6 +685,7 @@ public class ActionManagerImpl implements ActionManager {
}
if (payload != null) {
// get artifact data from action_artifact table for updating
+
// the content
ActionArtifact artifactContent = new ActionArtifact();
artifactContent.setArtifactUuId(artifact.getArtifactUuId());
@@ -788,32 +697,28 @@ public class ActionManagerImpl implements ActionManager {
artifactMetadataByUuId.setTimestamp(getCurrentTimeStampUtc());
updateArtifactMetadataInActionData(action, artifactMetadataByUuId);
}
- log.debug("exit updateArtifact with actionInvariantUuId= " + actionInvariantUuId + ARTIFACT_UUID
- + artifact.getArtifactUuId() + " and user = " + user);
+ log.debug(
+ "exit updateArtifact with actionInvariantUuId= " + actionInvariantUuId + ARTIFACT_UUID + artifact.getArtifactUuId() + " and user = "
+ + user);
} catch (CoreException coreException) {
formAndThrowException(coreException);
}
}
/**
- * Generate artifact UUID at runtime using action name and effective
- * version.
+ * Generate artifact UUID at runtime using action name and effective version.
*
- * @param action
- * {@link Action} for which the artifact is being
- * uploaded/updated/downloaded
- * @param artifactName
- * Artifact name
+ * @param action {@link Action} for which the artifact is being uploaded/updated/downloaded
+ * @param artifactName Artifact name
* @return Generated UUID string
*/
private String generateActionArtifactUuId(Action action, String artifactName) {
int effectiveVersion = getEffectiveVersion(action.getVersion());
// Upper case for maintaining case-insensitive behavior for the artifact
+
// names
- String artifactUuIdString = action.getName()
- .toUpperCase() + effectiveVersion + artifactName.toUpperCase();
- String generateArtifactUuId = UUID.nameUUIDFromBytes((artifactUuIdString).getBytes())
- .toString();
+ String artifactUuIdString = action.getName().toUpperCase() + effectiveVersion + artifactName.toUpperCase();
+ String generateArtifactUuId = UUID.nameUUIDFromBytes((artifactUuIdString).getBytes()).toString();
String artifactUuId = generateArtifactUuId.replace("-", "");
return artifactUuId.toUpperCase();
}
@@ -821,8 +726,7 @@ public class ActionManagerImpl implements ActionManager {
/**
* Generate the effective action version for artifact operations.
*
- * @param actionVersion
- * Version of the action as a string
+ * @param actionVersion Version of the action as a string
* @return Effective version to be used for artifact operations
*/
private int getEffectiveVersion(String actionVersion) {
@@ -831,11 +735,9 @@ public class ActionManagerImpl implements ActionManager {
}
/**
- * Update the data field of the Action object with the modified/generated
- * fields after an operation.
+ * Update the data field of the Action object with the modified/generated fields after an operation.
*
- * @param action
- * Action object whose data field has to be updated
+ * @param action Action object whose data field has to be updated
* @return Updated {@link Action} object
*/
private Action updateData(Action action) {
@@ -844,9 +746,7 @@ public class ActionManagerImpl implements ActionManager {
dataMap.put(ActionConstants.UNIQUE_ID, action.getActionUuId());
dataMap.put(ActionConstants.VERSION, action.getVersion());
dataMap.put(ActionConstants.INVARIANTUUID, action.getActionInvariantUuId());
- dataMap.put(ActionConstants.STATUS, action.getStatus()
- .name());
-
+ dataMap.put(ActionConstants.STATUS, action.getStatus().name());
String data = action.getData();
Map<String, String> currentDataMap = JsonUtil.json2Object(data, LinkedHashMap.class);
dataMap.putAll(currentDataMap);
@@ -857,16 +757,12 @@ public class ActionManagerImpl implements ActionManager {
}
/**
- * Method to add the artifact metadata in the data attribute of action
- * table.
+ * Method to add the artifact metadata in the data attribute of action table.
*
- * @param action
- * Action to which artifact is uploaded
- * @param artifact
- * Uploaded artifact object
+ * @param action Action to which artifact is uploaded
+ * @param artifact Uploaded artifact object
*/
private void addArtifactMetadataInActionData(Action action, ActionArtifact artifact) {
-
ActionArtifact artifactMetadata = new ActionArtifact();
artifactMetadata.setArtifactUuId(artifact.getArtifactUuId());
artifactMetadata.setArtifactName(artifact.getArtifactName());
@@ -875,7 +771,6 @@ public class ActionManagerImpl implements ActionManager {
artifactMetadata.setArtifactDescription(artifact.getArtifactDescription());
artifactMetadata.setArtifactCategory(artifact.getArtifactCategory());
artifactMetadata.setTimestamp(artifact.getTimestamp());
-
List<ActionArtifact> actionArtifacts = action.getArtifacts();
if (actionArtifacts == null) {
actionArtifacts = new ArrayList<>();
@@ -892,20 +787,17 @@ public class ActionManagerImpl implements ActionManager {
}
/**
- * Get a list of last major and last minor version (no candidate) of action
- * from a list of actions.
+ * Get a list of last major and last minor version (no candidate) of action from a list of actions.
*
- * @param actions
- * Exhaustive list of the action versions
- * @return List {@link Action} of last major and last minor version (no
- * candidate) of action from a list of actions
+ * @param actions Exhaustive list of the action versions
+ * @return List {@link Action} of last major and last minor version (no candidate) of action from a list of actions
*/
private List<Action> getMajorMinorVersionActions(List<Action> actions) {
log.debug(" entering getMajorMinorVersionActions for actions ");
List<Action> list = new LinkedList<>();
actionLogPreProcessor(ActionSubOperation.GET_VERSIONINFO_FOR_ALL_ACTIONS, TARGET_ENTITY_API);
- Map<String, VersionInfo> actionVersionMap = versioningManager.listEntitiesVersionInfo(ACTION_VERSIONABLE_TYPE,
- "", VersionableEntityAction.Read);
+ Map<String, VersionInfo> actionVersionMap = versioningManager
+ .listEntitiesVersionInfo(ACTION_VERSIONABLE_TYPE, "", VersionableEntityAction.Read);
actionLogPostProcessor(COMPLETE);
log.metrics("");
for (Action action : actions) {
@@ -913,13 +805,11 @@ public class ActionManagerImpl implements ActionManager {
continue;
}
VersionInfo actionVersionInfo = actionVersionMap.get(action.getActionInvariantUuId());
- if (actionVersionInfo.getActiveVersion() != null && actionVersionInfo.getActiveVersion()
- .equals(Version.valueOf(action.getVersion()))) {
+ if (actionVersionInfo.getActiveVersion() != null && actionVersionInfo.getActiveVersion().equals(Version.valueOf(action.getVersion()))) {
list.add(action);
} else if (actionVersionInfo.getLatestFinalVersion() != null && actionVersionInfo.getLatestFinalVersion()
- .equals(Version.valueOf(action.getVersion()))
- && !actionVersionInfo.getLatestFinalVersion()
- .equals(actionVersionInfo.getActiveVersion())) {
+ .equals(Version.valueOf(action.getVersion())) && !actionVersionInfo.getLatestFinalVersion()
+ .equals(actionVersionInfo.getActiveVersion())) {
list.add(action);
}
}
@@ -928,99 +818,91 @@ public class ActionManagerImpl implements ActionManager {
}
/**
- * CoreException object wrapper from Version library to Action Library
- * Exception.
+ * CoreException object wrapper from Version library to Action Library Exception.
*
- * @param exception
- * CoreException object from version library
+ * @param exception CoreException object from version library
*/
private void formAndThrowException(CoreException exception) {
- log.debug("entering formAndThrowException with input CoreException =" + exception.code()
- .id() + " " + exception.getMessage());
+ log.debug("entering formAndThrowException with input CoreException =" + exception.code().id() + " " + exception.getMessage());
String errorDescription = exception.getMessage();
- String errorCode = exception.code()
- .id();
+ String errorCode = exception.code().id();
ActionException actionException = new ActionException();
switch (errorCode) {
- case VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST:
- actionException.setErrorCode(ACTION_ENTITY_NOT_EXIST_CODE);
- actionException.setDescription(ACTION_ENTITY_NOT_EXIST);
- break;
- case VersioningErrorCodes.CHECKOT_ON_LOCKED_ENTITY:
- actionException.setErrorCode(ACTION_CHECKOUT_ON_LOCKED_ENTITY);
- actionException.setDescription(errorDescription);
- break;
- case VersioningErrorCodes.CHECKIN_ON_UNLOCKED_ENTITY:
- actionException.setErrorCode(ACTION_CHECKIN_ON_UNLOCKED_ENTITY);
- actionException.setDescription(errorDescription);
- break;
- case VersioningErrorCodes.SUBMIT_FINALIZED_ENTITY_NOT_ALLOWED:
- actionException.setErrorCode(ACTION_SUBMIT_FINALIZED_ENTITY_NOT_ALLOWED);
- actionException.setDescription(errorDescription);
- break;
- case VersioningErrorCodes.SUBMIT_LOCKED_ENTITY_NOT_ALLOWED:
- actionException.setErrorCode(ACTION_SUBMIT_LOCKED_ENTITY_NOT_ALLOWED);
- actionException.setDescription(errorDescription);
- break;
- case VersioningErrorCodes.UNDO_CHECKOUT_ON_UNLOCKED_ENTITY:
- actionException.setErrorCode(ACTION_UNDO_CHECKOUT_ON_UNLOCKED_ENTITY);
- actionException.setDescription(errorDescription);
- break;
- case VersioningErrorCodes.EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER:
- actionException.setErrorCode(ACTION_EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER);
- actionException.setDescription(errorDescription.replace("edit", "updat"));
- break;
- case VersioningErrorCodes.CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER:
- actionException.setErrorCode(ACTION_CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER);
- actionException.setDescription(errorDescription);
- break;
- case VersioningErrorCodes.UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER:
- actionException.setErrorCode(ACTION_UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER);
- actionException.setDescription(errorDescription);
- break;
- case VersioningErrorCodes.EDIT_ON_UNLOCKED_ENTITY:
- actionException.setErrorCode(ACTION_UPDATE_ON_UNLOCKED_ENTITY);
- actionException.setDescription(errorDescription.replace("edit", "update"));
- break;
- case VersioningErrorCodes.DELETE_ON_LOCKED_ENTITY:
- actionException.setErrorCode(ACTION_DELETE_ON_LOCKED_ENTITY_CODE);
- actionException.setDescription(errorDescription);
- break;
- default:
- actionException.setErrorCode(ACTION_INTERNAL_SERVER_ERR_CODE);
- actionException.setDescription(exception.getMessage());
-
+ case VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST:
+ actionException.setErrorCode(ACTION_ENTITY_NOT_EXIST_CODE);
+ actionException.setDescription(ACTION_ENTITY_NOT_EXIST);
+ break;
+ case VersioningErrorCodes.CHECKOT_ON_LOCKED_ENTITY:
+ actionException.setErrorCode(ACTION_CHECKOUT_ON_LOCKED_ENTITY);
+ actionException.setDescription(errorDescription);
+ break;
+ case VersioningErrorCodes.CHECKIN_ON_UNLOCKED_ENTITY:
+ actionException.setErrorCode(ACTION_CHECKIN_ON_UNLOCKED_ENTITY);
+ actionException.setDescription(errorDescription);
+ break;
+ case VersioningErrorCodes.SUBMIT_FINALIZED_ENTITY_NOT_ALLOWED:
+ actionException.setErrorCode(ACTION_SUBMIT_FINALIZED_ENTITY_NOT_ALLOWED);
+ actionException.setDescription(errorDescription);
+ break;
+ case VersioningErrorCodes.SUBMIT_LOCKED_ENTITY_NOT_ALLOWED:
+ actionException.setErrorCode(ACTION_SUBMIT_LOCKED_ENTITY_NOT_ALLOWED);
+ actionException.setDescription(errorDescription);
+ break;
+ case VersioningErrorCodes.UNDO_CHECKOUT_ON_UNLOCKED_ENTITY:
+ actionException.setErrorCode(ACTION_UNDO_CHECKOUT_ON_UNLOCKED_ENTITY);
+ actionException.setDescription(errorDescription);
+ break;
+ case VersioningErrorCodes.EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER:
+ actionException.setErrorCode(ACTION_EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER);
+ actionException.setDescription(errorDescription.replace("edit", "updat"));
+ break;
+ case VersioningErrorCodes.CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER:
+ actionException.setErrorCode(ACTION_CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER);
+ actionException.setDescription(errorDescription);
+ break;
+ case VersioningErrorCodes.UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER:
+ actionException.setErrorCode(ACTION_UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER);
+ actionException.setDescription(errorDescription);
+ break;
+ case VersioningErrorCodes.EDIT_ON_UNLOCKED_ENTITY:
+ actionException.setErrorCode(ACTION_UPDATE_ON_UNLOCKED_ENTITY);
+ actionException.setDescription(errorDescription.replace("edit", "update"));
+ break;
+ case VersioningErrorCodes.DELETE_ON_LOCKED_ENTITY:
+ actionException.setErrorCode(ACTION_DELETE_ON_LOCKED_ENTITY_CODE);
+ actionException.setDescription(errorDescription);
+ break;
+ default:
+ actionException.setErrorCode(ACTION_INTERNAL_SERVER_ERR_CODE);
+ actionException.setDescription(exception.getMessage());
}
// Todo - Uncomment only if class to be added in ERROR Log
+
/*
* actionErrorLogProcessor(CategoryLogLevel.ERROR,
* actionException.getErrorCode(), actionException.getDescription());
* log.error("");
*/
- log.debug("exit formAndThrowException with ActionException =" + actionException.getErrorCode() + " "
- + actionException.getDescription());
+ log.debug("exit formAndThrowException with ActionException =" + actionException.getErrorCode() + " " + actionException.getDescription());
throw actionException;
}
/**
- * Validates an action object for business layer validations before an
- * update operation.
+ * Validates an action object for business layer validations before an update operation.
*
- * @param action
- * Action object to be validated
- * @param activeVersion
- * Active version of the actoin object
+ * @param action Action object to be validated
+ * @param activeVersion Active version of the actoin object
*/
private void validateActions(Action action, Version activeVersion) {
try {
// Set version if not already available in input request
+
// If version set in input compare it with version from DB
if (StringUtils.isEmpty(action.getVersion())) {
action.setVersion(activeVersion.toString());
} else {
if (!activeVersion.equals(Version.valueOf(action.getVersion()))) {
- throw new ActionException(ACTION_UPDATE_INVALID_VERSION,
- String.format(ACTION_REQUESTED_VERSION_INVALID, action.getVersion()));
+ throw new ActionException(ACTION_UPDATE_INVALID_VERSION, String.format(ACTION_REQUESTED_VERSION_INVALID, action.getVersion()));
}
}
String invariantUuId = action.getActionInvariantUuId();
@@ -1031,21 +913,18 @@ public class ActionManagerImpl implements ActionManager {
}
List<String> invalidParameters = new LinkedList<>();
// Prevent update of name, version and id fields
- if (!existingAction.getName()
- .equals(action.getName())) {
+ if (!existingAction.getName().equals(action.getName())) {
throw new ActionException(ACTION_UPDATE_NOT_ALLOWED_CODE_NAME, ACTION_UPDATE_NOT_ALLOWED_FOR_NAME);
}
- if (!StringUtils.isEmpty(action.getActionUuId()) && !existingAction.getActionUuId()
- .equals(action.getActionUuId())) {
+ if (!StringUtils.isEmpty(action.getActionUuId()) && !existingAction.getActionUuId().equals(action.getActionUuId())) {
invalidParameters.add(UNIQUE_ID);
}
if (action.getStatus() != null && (existingAction.getStatus() != action.getStatus())) {
invalidParameters.add(STATUS);
}
-
if (!invalidParameters.isEmpty()) {
throw new ActionException(ACTION_UPDATE_NOT_ALLOWED_CODE,
- String.format(ACTION_UPDATE_PARAM_INVALID, StringUtils.join(invalidParameters, ", ")));
+ String.format(ACTION_UPDATE_PARAM_INVALID, StringUtils.join(invalidParameters, ", ")));
}
action.setActionUuId(existingAction.getActionUuId());
} catch (IllegalArgumentException iae) {
@@ -1061,10 +940,8 @@ public class ActionManagerImpl implements ActionManager {
/**
* Get an action version entity object.
*
- * @param invariantUuId
- * Invariant UUID of the action
- * @param version
- * Version of the action
+ * @param invariantUuId Invariant UUID of the action
+ * @param version Version of the action
* @return {@link ActionEntity} object of the action version
*/
private ActionEntity getActionsEntityByVersion(String invariantUuId, Version version) {
@@ -1072,8 +949,7 @@ public class ActionManagerImpl implements ActionManager {
ActionEntity entity = null;
if (version != null) {
actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_VERSION, TARGET_ENTITY_DB);
- entity = actionDao
- .get(new ActionEntity(invariantUuId != null ? invariantUuId.toUpperCase() : null, version));
+ entity = actionDao.get(new ActionEntity(invariantUuId != null ? invariantUuId.toUpperCase() : null, version));
actionLogPostProcessor(COMPLETE);
log.metrics("");
}
@@ -1084,34 +960,27 @@ public class ActionManagerImpl implements ActionManager {
/**
* Get an action version object.
*
- * @param invariantUuId
- * Invariant UUID of the action
- * @param version
- * Version of the action
+ * @param invariantUuId Invariant UUID of the action
+ * @param version Version of the action
* @return {@link Action} object of the action version
*/
private Action getActions(String invariantUuId, Version version) {
- ActionEntity actionEntity = getActionsEntityByVersion(
- invariantUuId != null ? invariantUuId.toUpperCase() : null, version);
+ ActionEntity actionEntity = getActionsEntityByVersion(invariantUuId != null ? invariantUuId.toUpperCase() : null, version);
return actionEntity != null ? actionEntity.toDto() : new Action();
}
/**
* Create and set the Unique ID in for an action version row.
*
- * @param invariantUuId
- * Invariant UUID of the action
- * @param version
- * Version of the action
- * @param status
- * Status of the action
- * @param user
- * AT&T id of the user sending the request
+ * @param invariantUuId Invariant UUID of the action
+ * @param version Version of the action
+ * @param status Status of the action
+ * @param user AT&T id of the user sending the request
* @return {@link ActionEntity} object of the action version
*/
private ActionEntity updateUniqueIdForVersion(String invariantUuId, Version version, String status, String user) {
- log.debug("entering updateUniqueIdForVersion to update action with invariantUuId= " + invariantUuId
- + " with version,status and user as ::" + version + " " + status + " " + user);
+ log.debug("entering updateUniqueIdForVersion to update action with invariantUuId= " + invariantUuId + " with version,status and user as ::"
+ + version + " " + status + " " + user);
// generate UUID AND update for newly created entity row
ActionEntity actionEntity = getActionsEntityByVersion(invariantUuId, version);
if (actionEntity != null) {
@@ -1123,7 +992,6 @@ public class ActionManagerImpl implements ActionManager {
dataMap.put(ActionConstants.VERSION, version.toString());
dataMap.put(ActionConstants.STATUS, status);
data = JsonUtil.object2Json(dataMap);
-
actionEntity.setData(data);
actionEntity.setActionUuId(uniqueId);
actionEntity.setStatus(status);
@@ -1134,7 +1002,6 @@ public class ActionManagerImpl implements ActionManager {
actionLogPostProcessor(COMPLETE);
log.metrics("");
}
-
log.debug("exit updateUniqueIdForVersion to update action with invariantUUID= " + invariantUuId);
return actionEntity;
}
@@ -1142,19 +1009,15 @@ public class ActionManagerImpl implements ActionManager {
/**
* Set the status for an action version row.
*
- * @param invariantUuId
- * Invariant UUID of the action
- * @param version
- * Version of the action
- * @param status
- * Status of the action
- * @param user
- * AT&T id of the user sending the request
+ * @param invariantUuId Invariant UUID of the action
+ * @param version Version of the action
+ * @param status Status of the action
+ * @param user AT&T id of the user sending the request
* @return {@link ActionEntity} object of the action version
*/
private ActionEntity updateStatusForVersion(String invariantUuId, Version version, String status, String user) {
- log.debug("entering updateStatusForVersion with invariantUuId= " + invariantUuId + AND_VERSION + version
- + " for updating status " + status + " by user " + user);
+ log.debug("entering updateStatusForVersion with invariantUuId= " + invariantUuId + AND_VERSION + version + " for updating status " + status
+ + " by user " + user);
ActionEntity actionEntity = getActionsEntityByVersion(invariantUuId, version);
if (actionEntity != null) {
String data = actionEntity.getData();
@@ -1170,46 +1033,40 @@ public class ActionManagerImpl implements ActionManager {
actionLogPostProcessor(COMPLETE);
log.metrics("");
}
- log.debug("exit updateStatusForVersion with invariantUuId= " + invariantUuId + AND_VERSION + version
- + " for updating status " + status + " by user " + user);
+ log.debug("exit updateStatusForVersion with invariantUuId= " + invariantUuId + AND_VERSION + version + " for updating status " + status
+ + " by user " + user);
return actionEntity;
-
}
/**
* Gets an artifact from the action artifact metadata by artifact name.
*
- * @param actionArtifactList
- * Action's existing artifact list
- * @param artifactFilterType
- * Search criteria for artifact in action artifact metadata
- * @param artifactFilterValue
- * Value of Search parameter
- * @return Artifact metadata object if artifact is present in action and
- * null otherwise
+ * @param actionArtifactList Action's existing artifact list
+ * @param artifactFilterType Search criteria for artifact in action artifact metadata
+ * @param artifactFilterValue Value of Search parameter
+ * @return Artifact metadata object if artifact is present in action and null otherwise
*/
- private ActionArtifact getArtifactMetadataFromAction(List<ActionArtifact> actionArtifactList,
- String artifactFilterType, String artifactFilterValue) {
+ private ActionArtifact getArtifactMetadataFromAction(List<ActionArtifact> actionArtifactList, String artifactFilterType,
+ String artifactFilterValue) {
ActionArtifact artifact = null;
if (actionArtifactList != null && !actionArtifactList.isEmpty()) {
for (ActionArtifact entry : actionArtifactList) {
switch (artifactFilterType) {
- case ARTIFACT_METADATA_ATTR_UUID:
- String artifactUuId = entry.getArtifactUuId();
- if (artifactUuId != null && artifactUuId.equals(artifactFilterValue)) {
- artifact = entry;
+ case ARTIFACT_METADATA_ATTR_UUID:
+ String artifactUuId = entry.getArtifactUuId();
+ if (artifactUuId != null && artifactUuId.equals(artifactFilterValue)) {
+ artifact = entry;
+ break;
+ }
break;
- }
- break;
- case ARTIFACT_METADATA_ATTR_NAME:
- String existingArtifactName = entry.getArtifactName()
- .toLowerCase();
- if (existingArtifactName.equals(artifactFilterValue.toLowerCase())) {
- artifact = entry;
+ case ARTIFACT_METADATA_ATTR_NAME:
+ String existingArtifactName = entry.getArtifactName().toLowerCase();
+ if (existingArtifactName.equals(artifactFilterValue.toLowerCase())) {
+ artifact = entry;
+ break;
+ }
break;
- }
- break;
- default:
+ default:
}
}
}
@@ -1217,18 +1074,14 @@ public class ActionManagerImpl implements ActionManager {
}
/**
- * Method to update the artifact metadata in the data attribute of action
- * table.
+ * Method to update the artifact metadata in the data attribute of action table.
*
- * @param action
- * Action to which artifact is uploaded
- * @param updatedArtifact
- * updated artifact object
+ * @param action Action to which artifact is uploaded
+ * @param updatedArtifact updated artifact object
*/
private void updateArtifactMetadataInActionData(Action action, ActionArtifact updatedArtifact) {
for (ActionArtifact entry : action.getArtifacts()) {
- if (entry.getArtifactUuId()
- .equals(updatedArtifact.getArtifactUuId())) {
+ if (entry.getArtifactUuId().equals(updatedArtifact.getArtifactUuId())) {
entry.setArtifactLabel(updatedArtifact.getArtifactLabel());
entry.setArtifactCategory(updatedArtifact.getArtifactCategory());
entry.setArtifactDescription(updatedArtifact.getArtifactDescription());
diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManager.java b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManager.java
index 8499e7a96a..cd8a9571c0 100644
--- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManager.java
+++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManager.java
@@ -13,17 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.activitylog;
+import java.util.Collection;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Collection;
-
public interface ActivityLogManager {
- void logActivity(ActivityLogEntity activityLogEntity);
+ void logActivity(ActivityLogEntity activityLogEntity);
- Collection<ActivityLogEntity> listLoggedActivities(String itemId, Version versionId);
+ Collection<ActivityLogEntity> listLoggedActivities(String itemId, Version versionId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManagerFactory.java b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManagerFactory.java
index 639345c7f0..fbfcc4a4df 100644
--- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManagerFactory.java
@@ -18,8 +18,8 @@ package org.openecomp.sdc.activitylog;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
-
public abstract class ActivityLogManagerFactory extends AbstractComponentFactory<ActivityLogManager> {
+
public static ActivityLogManagerFactory getInstance() {
return AbstractFactory.getInstance(ActivityLogManagerFactory.class);
}
diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImpl.java
index c1dd5d0a75..31819dc1c7 100644
--- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImpl.java
@@ -20,19 +20,19 @@ import org.openecomp.sdc.activitylog.ActivityLogManagerFactory;
import org.openecomp.sdc.activitylog.dao.ActivityLogDaoFactory;
public class ActivityLogManagerFactoryImpl extends ActivityLogManagerFactory {
- private final ActivityLogManager INSTANCE;
+ private final ActivityLogManager INSTANCE;
- public ActivityLogManagerFactoryImpl() {
- this.INSTANCE = new ActivityLogManagerImpl(ActivityLogDaoFactory.getInstance().createInterface());
- }
+ public ActivityLogManagerFactoryImpl() {
+ this.INSTANCE = new ActivityLogManagerImpl(ActivityLogDaoFactory.getInstance().createInterface());
+ }
- ActivityLogManagerFactoryImpl(ActivityLogManager activityLogManager) {
- this.INSTANCE = activityLogManager;
- }
+ ActivityLogManagerFactoryImpl(ActivityLogManager activityLogManager) {
+ this.INSTANCE = activityLogManager;
+ }
- @Override
- public ActivityLogManager createInterface() {
- return INSTANCE;
- }
+ @Override
+ public ActivityLogManager createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImpl.java b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImpl.java
index 39a2d5c962..2b4e5c95de 100644
--- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImpl.java
@@ -13,32 +13,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.activitylog.impl;
+import java.util.Collection;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.sdc.activitylog.ActivityLogManager;
import org.openecomp.sdc.activitylog.dao.ActivityLogDao;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Collection;
-
public class ActivityLogManagerImpl implements ActivityLogManager {
- private ActivityLogDao activityLogDao;
- public ActivityLogManagerImpl(ActivityLogDao activityLogDao) {
- this.activityLogDao = activityLogDao;
- }
+ private ActivityLogDao activityLogDao;
+
+ public ActivityLogManagerImpl(ActivityLogDao activityLogDao) {
+ this.activityLogDao = activityLogDao;
+ }
- @Override
- public void logActivity(ActivityLogEntity activityLogEntity) {
- activityLogEntity.setId(CommonMethods.nextUuId());
- activityLogDao.create(activityLogEntity);
- }
+ @Override
+ public void logActivity(ActivityLogEntity activityLogEntity) {
+ activityLogEntity.setId(CommonMethods.nextUuId());
+ activityLogDao.create(activityLogEntity);
+ }
- @Override
- public Collection<ActivityLogEntity> listLoggedActivities(String itemId, Version version) {
- return activityLogDao.list(new ActivityLogEntity(itemId, version));
- }
+ @Override
+ public Collection<ActivityLogEntity> listLoggedActivities(String itemId, Version version) {
+ return activityLogDao.list(new ActivityLogEntity(itemId, version));
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-application-config-manager/src/main/java/org/openecomp/sdc/applicationconfig/ApplicationConfigManager.java b/openecomp-be/backend/openecomp-sdc-application-config-manager/src/main/java/org/openecomp/sdc/applicationconfig/ApplicationConfigManager.java
index ff95e5af3c..74c7193018 100644
--- a/openecomp-be/backend/openecomp-sdc-application-config-manager/src/main/java/org/openecomp/sdc/applicationconfig/ApplicationConfigManager.java
+++ b/openecomp-be/backend/openecomp-sdc-application-config-manager/src/main/java/org/openecomp/sdc/applicationconfig/ApplicationConfigManager.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,22 +17,20 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.applicationconfig;
+import java.util.Collection;
import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity;
import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData;
-import java.util.Collection;
-
/**
* Created by Talio on 8/8/2016.
*/
public interface ApplicationConfigManager {
- void insertIntoTable(String namespace, String key, String value);
+ void insertIntoTable(String namespace, String key, String value);
- ConfigurationData getFromTable(String namespace, String key);
+ ConfigurationData getFromTable(String namespace, String key);
- Collection<ApplicationConfigEntity> getListOfConfigurationByNamespace(String namespace);
+ Collection<ApplicationConfigEntity> getListOfConfigurationByNamespace(String namespace);
}
diff --git a/openecomp-be/backend/openecomp-sdc-application-config-manager/src/main/java/org/openecomp/sdc/applicationconfig/impl/ApplicationConfigManagerImpl.java b/openecomp-be/backend/openecomp-sdc-application-config-manager/src/main/java/org/openecomp/sdc/applicationconfig/impl/ApplicationConfigManagerImpl.java
index bc9354f221..9c164b74c3 100644
--- a/openecomp-be/backend/openecomp-sdc-application-config-manager/src/main/java/org/openecomp/sdc/applicationconfig/impl/ApplicationConfigManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-application-config-manager/src/main/java/org/openecomp/sdc/applicationconfig/impl/ApplicationConfigManagerImpl.java
@@ -12,10 +12,10 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-*/
-
+ */
package org.openecomp.sdc.applicationconfig.impl;
+import java.util.Collection;
import org.openecomp.core.utilities.applicationconfig.ApplicationConfig;
import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity;
import org.openecomp.core.utilities.applicationconfig.impl.ApplicationConfigImpl;
@@ -25,37 +25,33 @@ import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-import java.util.Collection;
-
/**
* Created by Talio on 8/8/2016.
*/
public class ApplicationConfigManagerImpl implements ApplicationConfigManager {
- private static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR =
- "SCHEMA_GENERATOR_INITIALIZATION_ERROR";
- private static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG =
- "Error occurred while loading questionnaire schema templates";
- private ApplicationConfig applicationConfig = new ApplicationConfigImpl();
-
- @Override
- public void insertIntoTable(String namespace, String key, String value) {
- try {
- applicationConfig.insertValue(namespace, key, value);
- } catch (Exception exception) {
- throw new CoreException(new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory
- .APPLICATION).withId(SCHEMA_GENERATOR_INITIALIZATION_ERROR).withMessage(
- SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG).build(), exception);
+ private static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR = "SCHEMA_GENERATOR_INITIALIZATION_ERROR";
+ private static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG = "Error occurred while loading questionnaire schema templates";
+ private ApplicationConfig applicationConfig = new ApplicationConfigImpl();
+
+ @Override
+ public void insertIntoTable(String namespace, String key, String value) {
+ try {
+ applicationConfig.insertValue(namespace, key, value);
+ } catch (Exception exception) {
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).withId(SCHEMA_GENERATOR_INITIALIZATION_ERROR)
+ .withMessage(SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG).build(), exception);
+ }
}
- }
- @Override
- public ConfigurationData getFromTable(String namespace, String key) {
- return applicationConfig.getConfigurationData(namespace, key);
- }
+ @Override
+ public ConfigurationData getFromTable(String namespace, String key) {
+ return applicationConfig.getConfigurationData(namespace, key);
+ }
- @Override
- public Collection<ApplicationConfigEntity> getListOfConfigurationByNamespace(String namespace) {
- return applicationConfig.getListOfConfigurationByNamespace(namespace);
- }
+ @Override
+ public Collection<ApplicationConfigEntity> getListOfConfigurationByNamespace(String namespace) {
+ return applicationConfig.getListOfConfigurationByNamespace(namespace);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManager.java b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManager.java
index 28c32e049f..1231469f31 100644
--- a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManager.java
+++ b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManager.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.conflicts;
import org.openecomp.conflicts.types.Conflict;
@@ -27,14 +26,13 @@ import org.openecomp.sdc.versioning.dao.types.Version;
public interface ConflictsManager {
- boolean isConflicted(String itemId, Version version);
+ boolean isConflicted(String itemId, Version version);
- ItemVersionConflict getConflict(String itemId, Version version);
+ ItemVersionConflict getConflict(String itemId, Version version);
- void finalizeMerge(String itemId, Version version);
+ void finalizeMerge(String itemId, Version version);
- Conflict getConflict(String itemId, Version version, String conflictId);
+ Conflict getConflict(String itemId, Version version, String conflictId);
- void resolveConflict(String itemId, Version version, String conflictId,
- ConflictResolution resolution);
+ void resolveConflict(String itemId, Version version, String conflictId, ConflictResolution resolution);
}
diff --git a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManagerFactory.java b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManagerFactory.java
index 7a24cfd311..b13a4329c3 100644
--- a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManagerFactory.java
@@ -22,8 +22,8 @@ package org.openecomp.sdc.conflicts;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
-
public abstract class ConflictsManagerFactory extends AbstractComponentFactory<ConflictsManager> {
+
public static ConflictsManagerFactory getInstance() {
return AbstractFactory.getInstance(ConflictsManagerFactory.class);
}
diff --git a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerFactoryImpl.java
index 2d703c4a87..72347580b0 100644
--- a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerFactoryImpl.java
@@ -19,17 +19,16 @@
*/
package org.openecomp.sdc.conflicts.impl;
-
import org.openecomp.conflicts.dao.ConflictsDaoFactory;
import org.openecomp.sdc.conflicts.ConflictsManager;
import org.openecomp.sdc.conflicts.ConflictsManagerFactory;
public class ConflictsManagerFactoryImpl extends ConflictsManagerFactory {
- private static final ConflictsManager INSTANCE =
- new ConflictsManagerImpl(ConflictsDaoFactory.getInstance().createInterface());
- @Override
- public ConflictsManager createInterface() {
- return INSTANCE;
- }
+ private static final ConflictsManager INSTANCE = new ConflictsManagerImpl(ConflictsDaoFactory.getInstance().createInterface());
+
+ @Override
+ public ConflictsManager createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerImpl.java b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerImpl.java
index 284823baac..5ae23783c4 100644
--- a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerImpl.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,9 +17,9 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.conflicts.impl;
+import java.util.Optional;
import org.openecomp.conflicts.ItemMergeHandler;
import org.openecomp.conflicts.ItemMergeHandlerFactory;
import org.openecomp.conflicts.dao.ConflictsDao;
@@ -33,100 +33,67 @@ import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.conflicts.ConflictsManager;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Optional;
-
public class ConflictsManagerImpl implements ConflictsManager {
- private static final String ELEMENT_CONFLICT_NOT_EXIST_ERR_ID = "ELEMENT_CONFLICT_NOT_EXIST";
- private static final String ELEMENT_CONFLICT_NOT_EXISTS_MSG =
- "Item Id %s, version Id %s, element conflict with Id %s does not exists.";
-
- private final ConflictsDao conflictsDao;
-
- public ConflictsManagerImpl(ConflictsDao conflictsDao) {
- this.conflictsDao = conflictsDao;
- }
-
- @Override
- public boolean isConflicted(String itemId, Version version) {
- Optional<ItemMergeHandler> itemMergeHandler =
- ItemMergeHandlerFactory.getInstance().createInterface(itemId);
-
- return conflictsDao.isConflicted(itemId, version) ||
- (itemMergeHandler.isPresent() &&
- itemMergeHandler.get().isConflicted(itemId, version));
- }
-
- @Override
- public ItemVersionConflict getConflict(String itemId, Version version) {
- ItemVersionConflict conflicts = conflictsDao.getConflict(itemId, version);
+ private static final String ELEMENT_CONFLICT_NOT_EXIST_ERR_ID = "ELEMENT_CONFLICT_NOT_EXIST";
+ private static final String ELEMENT_CONFLICT_NOT_EXISTS_MSG = "Item Id %s, version Id %s, element conflict with Id %s does not exists.";
+ private final ConflictsDao conflictsDao;
- ItemMergeHandlerFactory.getInstance().createInterface(itemId)
- .ifPresent(itemMergeHandler -> itemMergeHandler
- .postListConflicts(itemId, version, conflicts));
-
- return conflicts;
- }
-
- @Override
- public void finalizeMerge(String itemId, Version version) {
- ItemMergeHandlerFactory.getInstance().createInterface(itemId)
- .ifPresent(mergeHandler -> mergeHandler.finalizeMerge(itemId, version));
- }
-
- @Override
- public Conflict getConflict(String itemId, Version version, String conflictId) {
- Optional<ItemMergeHandler> itemMergeHandler =
- ItemMergeHandlerFactory.getInstance().createInterface(itemId);
- if (itemMergeHandler.isPresent()) {
- Optional<Conflict> conflict =
- itemMergeHandler.get().getConflict(itemId, version, conflictId);
- if (conflict.isPresent()) {
- return conflict.get();
- }
+ public ConflictsManagerImpl(ConflictsDao conflictsDao) {
+ this.conflictsDao = conflictsDao;
}
- Conflict conflict = conflictsDao.getConflict(itemId, version, conflictId);
-
- itemMergeHandler.ifPresent(mergeHandler ->
- mergeHandler.postGetConflict(itemId, version, conflict));
-
- if (conflict == null) {
- throw getConflictNotExistException(itemId, version, conflictId);
+ @Override
+ public boolean isConflicted(String itemId, Version version) {
+ Optional<ItemMergeHandler> itemMergeHandler = ItemMergeHandlerFactory.getInstance().createInterface(itemId);
+ return conflictsDao.isConflicted(itemId, version) || (itemMergeHandler.isPresent() && itemMergeHandler.get().isConflicted(itemId, version));
}
- return conflict;
- }
- @Override
- public void resolveConflict(String itemId, Version version, String conflictId,
- ConflictResolution resolution) {
- if (Resolution.OTHER.equals(resolution.getResolution())) {
- throw new UnsupportedOperationException(
- "Resolution other than 'THEIRS' or 'YOURS' is not supported.");
+ @Override
+ public ItemVersionConflict getConflict(String itemId, Version version) {
+ ItemVersionConflict conflicts = conflictsDao.getConflict(itemId, version);
+ ItemMergeHandlerFactory.getInstance().createInterface(itemId)
+ .ifPresent(itemMergeHandler -> itemMergeHandler.postListConflicts(itemId, version, conflicts));
+ return conflicts;
}
- Optional<ItemMergeHandler> itemMergeHandler =
- ItemMergeHandlerFactory.getInstance().createInterface(itemId);
- if (!itemMergeHandler.isPresent() ||
- !itemMergeHandler.get()
- .resolveConflict(itemId, version, conflictId, resolution)) {
-
- getConflict(itemId, version, conflictId); // validate that the conflict exist
- itemMergeHandler.ifPresent(mergeHandler ->
- mergeHandler.preResolveConflict(itemId, version, conflictId, resolution));
+ @Override
+ public void finalizeMerge(String itemId, Version version) {
+ ItemMergeHandlerFactory.getInstance().createInterface(itemId).ifPresent(mergeHandler -> mergeHandler.finalizeMerge(itemId, version));
+ }
- conflictsDao.resolveConflict(itemId, version, conflictId, resolution);
+ @Override
+ public Conflict getConflict(String itemId, Version version, String conflictId) {
+ Optional<ItemMergeHandler> itemMergeHandler = ItemMergeHandlerFactory.getInstance().createInterface(itemId);
+ if (itemMergeHandler.isPresent()) {
+ Optional<Conflict> conflict = itemMergeHandler.get().getConflict(itemId, version, conflictId);
+ if (conflict.isPresent()) {
+ return conflict.get();
+ }
+ }
+ Conflict conflict = conflictsDao.getConflict(itemId, version, conflictId);
+ itemMergeHandler.ifPresent(mergeHandler -> mergeHandler.postGetConflict(itemId, version, conflict));
+ if (conflict == null) {
+ throw getConflictNotExistException(itemId, version, conflictId);
+ }
+ return conflict;
}
- }
- private CoreException getConflictNotExistException(String itemId, Version version,
- String conflictId) {
- return new CoreException(new ErrorCode.ErrorCodeBuilder()
- .withCategory(ErrorCategory.APPLICATION)
- .withId(ELEMENT_CONFLICT_NOT_EXIST_ERR_ID)
- .withMessage(
- String.format(ELEMENT_CONFLICT_NOT_EXISTS_MSG, itemId, version.getId(), conflictId))
- .build());
- }
+ @Override
+ public void resolveConflict(String itemId, Version version, String conflictId, ConflictResolution resolution) {
+ if (Resolution.OTHER.equals(resolution.getResolution())) {
+ throw new UnsupportedOperationException("Resolution other than 'THEIRS' or 'YOURS' is not supported.");
+ }
+ Optional<ItemMergeHandler> itemMergeHandler = ItemMergeHandlerFactory.getInstance().createInterface(itemId);
+ if (!itemMergeHandler.isPresent() || !itemMergeHandler.get().resolveConflict(itemId, version, conflictId, resolution)) {
+ getConflict(itemId, version, conflictId); // validate that the conflict exist
+ itemMergeHandler.ifPresent(mergeHandler -> mergeHandler.preResolveConflict(itemId, version, conflictId, resolution));
+ conflictsDao.resolveConflict(itemId, version, conflictId, resolution);
+ }
+ }
+ private CoreException getConflictNotExistException(String itemId, Version version, String conflictId) {
+ return new CoreException(new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).withId(ELEMENT_CONFLICT_NOT_EXIST_ERR_ID)
+ .withMessage(String.format(ELEMENT_CONFLICT_NOT_EXISTS_MSG, itemId, version.getId(), conflictId)).build());
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDao.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDao.java
index 947387b4a6..0f1351e9bb 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDao.java
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDao.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,10 +17,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.health;
public interface HealthCheckDao {
- boolean checkHealth() throws Exception;
- String getVersion();
+
+ boolean checkHealth() throws Exception;
+
+ String getVersion();
}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDaoFactory.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDaoFactory.java
index 387d24d07c..d76eee25ef 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDaoFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDaoFactory.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,14 +17,14 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.health;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
public abstract class HealthCheckDaoFactory extends AbstractComponentFactory<HealthCheckDao> {
- public static HealthCheckDaoFactory getInstance() {
- return AbstractFactory.getInstance(HealthCheckDaoFactory.class);
- }
+
+ public static HealthCheckDaoFactory getInstance() {
+ return AbstractFactory.getInstance(HealthCheckDaoFactory.class);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManager.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManager.java
index 0575d06058..6a543cbcf5 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManager.java
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManager.java
@@ -17,13 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.health;
-import org.openecomp.sdc.health.data.HealthInfo;
-
import java.util.Collection;
+import org.openecomp.sdc.health.data.HealthInfo;
public interface HealthCheckManager {
+
Collection<HealthInfo> checkHealth();
}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManagerFactory.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManagerFactory.java
index c3766068b2..00c3001496 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManagerFactory.java
@@ -22,8 +22,8 @@ package org.openecomp.sdc.health;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
-
public abstract class HealthCheckManagerFactory extends AbstractComponentFactory<HealthCheckManager> {
+
public static HealthCheckManagerFactory getInstance() {
return AbstractFactory.getInstance(HealthCheckManagerFactory.class);
}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckResult.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckResult.java
index bd47422a20..e243e7e555 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckResult.java
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckResult.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,14 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.health.data;
import java.util.Collection;
/**
- * {
- "sdcVersion": "1702.0.83.37.1",
+ * { "sdcVersion": "1702.0.83.37.1",
"componentsInfo": [
{
@@ -36,11 +34,11 @@ import java.util.Collection;
…..
]
}
-
*/
public class HealthCheckResult {
+
String sdcVersion;
- Collection<HealthInfo> componentsInfo;
+ Collection<HealthInfo> componentsInfo;
public HealthCheckResult() {
}
@@ -60,6 +58,4 @@ public class HealthCheckResult {
public void setComponentsInfo(Collection<HealthInfo> componentsInfo) {
this.componentsInfo = componentsInfo;
}
-
-
}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckStatus.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckStatus.java
index c5ef04477c..fccbe2a907 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckStatus.java
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckStatus.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,32 +17,27 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.health.data;
-
public enum HealthCheckStatus {
- UP("UP"),
- DOWN("DOWN");
-
+ UP("UP"), DOWN("DOWN");
private String name;
HealthCheckStatus(String name) {
this.name = name;
}
-
- @Override
- public String toString() {
- return name;
- }
-
- public static final HealthCheckStatus toValue(String inVal){
- for (HealthCheckStatus val : values()){
- if (val.toString().equals(inVal)){
+ public static final HealthCheckStatus toValue(String inVal) {
+ for (HealthCheckStatus val : values()) {
+ if (val.toString().equals(inVal)) {
return val;
}
}
return null;
}
+
+ @Override
+ public String toString() {
+ return name;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthInfo.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthInfo.java
index 3bb58fbaf3..bad6ebfb89 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthInfo.java
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthInfo.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.health.data;
/**
@@ -34,6 +33,7 @@ package org.openecomp.sdc.health.data;
}
*/
public class HealthInfo {
+
private MonitoredModules healthCheckComponent;
private HealthCheckStatus healthCheckStatus;
private String version;
@@ -83,11 +83,7 @@ public class HealthInfo {
@Override
public String toString() {
- return "HealthInfo{" +
- "healthCheckComponent='" + healthCheckComponent + '\'' +
- ", healthCheckStatus=" + healthCheckStatus +
- ", version='" + version + '\'' +
- ", description='" + description + '\'' +
- '}';
+ return "HealthInfo{" + "healthCheckComponent='" + healthCheckComponent + '\'' + ", healthCheckStatus=" + healthCheckStatus + ", version='"
+ + version + '\'' + ", description='" + description + '\'' + '}';
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/MonitoredModules.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/MonitoredModules.java
index b51d79095a..f990f64336 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/MonitoredModules.java
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/MonitoredModules.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,26 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.health.data;
-
public enum MonitoredModules {
- BE("BE"), CAS("Cassandra"),
- ZU("Zusammen");
-
+ BE("BE"), CAS("Cassandra"), ZU("Zusammen");
private String name;
MonitoredModules(String name) {
this.name = name;
}
-
- @Override
- public String toString() {
- return name;
- }
-
public static final MonitoredModules toValue(String inVal) {
for (MonitoredModules val : values()) {
if (val.toString().equals(inVal)) {
@@ -45,4 +35,9 @@ public enum MonitoredModules {
}
return null;
}
+
+ @Override
+ public String toString() {
+ return name;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/SiteMode.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/SiteMode.java
index 810dee5355..be2cd33b1f 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/SiteMode.java
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/SiteMode.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,25 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.health.data;
-
public enum SiteMode {
Active("active"), NOT_ACTIVE("NotActive");
-
private String name;
SiteMode(String name) {
this.name = name;
}
-
- @Override
- public String toString() {
- return name;
- }
-
public static final SiteMode toValue(String inVal) {
for (SiteMode val : values()) {
if (val.toString().equals(inVal)) {
@@ -44,4 +35,9 @@ public enum SiteMode {
}
return null;
}
+
+ @Override
+ public String toString() {
+ return name;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoFactoryImpl.java
index ec0931c90b..02291ed23c 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoFactoryImpl.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,20 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.health.impl;
-
import org.openecomp.sdc.health.HealthCheckDao;
import org.openecomp.sdc.health.HealthCheckDaoFactory;
-public class HealthCheckDaoFactoryImpl
- extends HealthCheckDaoFactory {
- private static final HealthCheckDao INSTANCE =
- new HealthCheckDaoImpl();
+public class HealthCheckDaoFactoryImpl extends HealthCheckDaoFactory {
+
+ private static final HealthCheckDao INSTANCE = new HealthCheckDaoImpl();
- @Override
- public HealthCheckDao createInterface() {
- return INSTANCE;
- }
+ @Override
+ public HealthCheckDao createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoImpl.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoImpl.java
index f9b4215322..340af95849 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoImpl.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,10 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.health.impl;
-
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.exceptions.DriverException;
import com.datastax.driver.mapping.annotations.Accessor;
@@ -34,9 +32,7 @@ import org.openecomp.sdc.logging.api.LoggerFactory;
public class HealthCheckDaoImpl implements HealthCheckDao {
private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
-
- private static final CheckHealthAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(CheckHealthAccessor.class);
+ private static final CheckHealthAccessor accessor = noSqlDb.getMappingManager().createAccessor(CheckHealthAccessor.class);
private static final Logger logger = LoggerFactory.getLogger(HealthCheckDaoImpl.class);
@Override
@@ -63,7 +59,5 @@ public class HealthCheckDaoImpl implements HealthCheckDao {
@Query("SELECT * FROM application_config LIMIT 1")
ResultSet checkHealth();
-
}
-
}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerFactoryImpl.java
index e5d85a2641..a50e5b15c2 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerFactoryImpl.java
@@ -23,12 +23,15 @@ import org.openecomp.sdc.health.HealthCheckManager;
import org.openecomp.sdc.health.HealthCheckManagerFactory;
public class HealthCheckManagerFactoryImpl extends HealthCheckManagerFactory {
- private static final HealthCheckManager INSTANCE ;
+
+ private static final HealthCheckManager INSTANCE;
static {
- INSTANCE = new HealthCheckManagerImpl();
+ INSTANCE = new HealthCheckManagerImpl();
}
@Override
- public HealthCheckManager createInterface() {return INSTANCE;}
+ public HealthCheckManager createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerImpl.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerImpl.java
index dba724565f..de4c79950e 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerImpl.java
@@ -13,12 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.health.impl;
import com.amdocs.zusammen.commons.health.data.HealthInfo;
import com.amdocs.zusammen.commons.health.data.HealthStatus;
import com.amdocs.zusammen.datatypes.SessionContext;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
import org.openecomp.core.zusammen.api.ZusammenUtil;
@@ -30,16 +34,9 @@ import org.openecomp.sdc.health.data.MonitoredModules;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-
public class HealthCheckManagerImpl implements HealthCheckManager {
private static final Logger LOGGER = LoggerFactory.getLogger(HealthCheckManagerImpl.class);
-
private HealthCheckDao healthCheckDao;
public HealthCheckManagerImpl() {
@@ -53,22 +50,19 @@ public class HealthCheckManagerImpl implements HealthCheckManager {
@Override
public Collection<org.openecomp.sdc.health.data.HealthInfo> checkHealth() {
org.openecomp.sdc.health.data.HealthInfo zeHealthInfo = null;
- org.openecomp.sdc.health.data.HealthInfo beHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(
- MonitoredModules.BE, HealthCheckStatus.UP, getBEVersion(), "OK");
+ org.openecomp.sdc.health.data.HealthInfo beHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(MonitoredModules.BE,
+ HealthCheckStatus.UP, getBEVersion(), "OK");
org.openecomp.sdc.health.data.HealthInfo cassandraHealthInfo = null;
String zVersion = "Unknown";
try {
SessionContext context = ZusammenUtil.createSessionContext();
- ZusammenAdaptor zusammenAdaptor = ZusammenAdaptorFactory
- .getInstance().createInterface();
+ ZusammenAdaptor zusammenAdaptor = ZusammenAdaptorFactory.getInstance().createInterface();
Collection<HealthInfo> zeHealthInfos = new ArrayList<>();
try {
zeHealthInfos = zusammenAdaptor.checkHealth(context);
} catch (Exception ex) {
LOGGER.error(ex.getMessage(), ex);
- zeHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(
- MonitoredModules.ZU, HealthCheckStatus.DOWN,
- zVersion, ex.getMessage());
+ zeHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(MonitoredModules.ZU, HealthCheckStatus.DOWN, zVersion, ex.getMessage());
}
boolean cassandraHealth = false;
String description = "OK";
@@ -77,47 +71,34 @@ public class HealthCheckManagerImpl implements HealthCheckManager {
} catch (Exception ex) {
LOGGER.error(ex.getMessage(), ex);
description = ex.getMessage();
- cassandraHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(
- MonitoredModules.CAS, HealthCheckStatus.DOWN, zVersion, ex.getMessage());
+ cassandraHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(MonitoredModules.CAS, HealthCheckStatus.DOWN, zVersion,
+ ex.getMessage());
}
zVersion = zusammenAdaptor.getVersion(context);
if (cassandraHealthInfo == null) {
HealthCheckStatus status = cassandraHealth ? HealthCheckStatus.UP : HealthCheckStatus.DOWN;
- if (!cassandraHealth){
+ if (!cassandraHealth) {
description = "Cassandra is not available";
}
- cassandraHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(MonitoredModules.CAS, status,
- healthCheckDao.getVersion(), description);
+ cassandraHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(MonitoredModules.CAS, status, healthCheckDao.getVersion(),
+ description);
}
if (zeHealthInfo == null) {
- List<HealthInfo> downHealth = zeHealthInfos.stream().
- filter(h -> h.getHealthStatus().equals(HealthStatus.DOWN)).
- collect(Collectors.toList());
-
+ List<HealthInfo> downHealth = zeHealthInfos.stream().filter(h -> h.getHealthStatus().equals(HealthStatus.DOWN))
+ .collect(Collectors.toList());
if (downHealth.isEmpty()) {
- zeHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(
- MonitoredModules.ZU, HealthCheckStatus.UP,
- zVersion, "OK");
+ zeHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(MonitoredModules.ZU, HealthCheckStatus.UP, zVersion, "OK");
} else {
- String desc = downHealth.stream().map(healthInfo -> healthInfo.getDescription())
- .collect(Collectors.joining(" , ", "[", "]"));
- zeHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(
- MonitoredModules.ZU, HealthCheckStatus.DOWN,
- zVersion, desc);
+ String desc = downHealth.stream().map(healthInfo -> healthInfo.getDescription()).collect(Collectors.joining(" , ", "[", "]"));
+ zeHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(MonitoredModules.ZU, HealthCheckStatus.DOWN, zVersion, desc);
}
-
}
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
- zeHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(
- MonitoredModules.ZU, HealthCheckStatus.DOWN, zVersion, e.getMessage()
- );
- cassandraHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(
- MonitoredModules.CAS, HealthCheckStatus.DOWN, zVersion, e.getMessage());
+ zeHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(MonitoredModules.ZU, HealthCheckStatus.DOWN, zVersion, e.getMessage());
+ cassandraHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(MonitoredModules.CAS, HealthCheckStatus.DOWN, zVersion,
+ e.getMessage());
}
return Arrays.asList(zeHealthInfo, beHealthInfo, cassandraHealthInfo);
}
-
-
}
-
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManager.java b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManager.java
index a7e8ca549d..d5e8ce0342 100644
--- a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManager.java
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManager.java
@@ -15,29 +15,25 @@
*/
package org.openecomp.sdc.itempermissions;
-import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
-
import java.util.Collection;
import java.util.Optional;
import java.util.Set;
+import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
/**
* Created by ayalaben on 6/18/2017.
*/
public interface PermissionsManager {
- Collection<ItemPermissionsEntity> listItemPermissions(String itemId);
-
- Set<String> listUserPermittedItems(String userId, String permission);
-
- void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
- Set<String> removedUsersIds);
+ Collection<ItemPermissionsEntity> listItemPermissions(String itemId);
- boolean isAllowed(String itemId, String userId, String action);
+ Set<String> listUserPermittedItems(String userId, String permission);
- Optional<String> getUserItemPermission(String itemId, String userId);
+ void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds, Set<String> removedUsersIds);
- void deleteItemPermissions(String itemId);
+ boolean isAllowed(String itemId, String userId, String action);
+ Optional<String> getUserItemPermission(String itemId, String userId);
+ void deleteItemPermissions(String itemId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManagerFactory.java b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManagerFactory.java
index 0353e5ce03..f37ccf9214 100644
--- a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManagerFactory.java
@@ -21,10 +21,9 @@ import org.openecomp.core.factory.api.AbstractFactory;
/**
* Created by ayalaben on 6/18/2017.
*/
-public abstract class PermissionsManagerFactory extends
- AbstractComponentFactory<PermissionsManager> {
+public abstract class PermissionsManagerFactory extends AbstractComponentFactory<PermissionsManager> {
- public static PermissionsManagerFactory getInstance() {
- return AbstractFactory.getInstance(PermissionsManagerFactory.class);
- }
+ public static PermissionsManagerFactory getInstance() {
+ return AbstractFactory.getInstance(PermissionsManagerFactory.class);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerFactoryImpl.java
index 14539b0fa1..3848b7c9a4 100644
--- a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerFactoryImpl.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.itempermissions.dao.impl;
import org.openecomp.sdc.itempermissions.PermissionsManager;
@@ -28,11 +27,9 @@ import org.openecomp.sdc.versioning.AsdcItemManagerFactory;
*/
public class PermissionsManagerFactoryImpl extends PermissionsManagerFactory {
- private static final PermissionsManager INSTANCE =
- new PermissionsManagerImpl(PermissionsServicesFactory.getInstance().createInterface(),
- AsdcItemManagerFactory.getInstance().createInterface(),
- NotificationPropagationManagerFactory.getInstance().createInterface(),
- SubscriptionServiceFactory.getInstance().createInterface());
+ private static final PermissionsManager INSTANCE = new PermissionsManagerImpl(PermissionsServicesFactory.getInstance().createInterface(),
+ AsdcItemManagerFactory.getInstance().createInterface(), NotificationPropagationManagerFactory.getInstance().createInterface(),
+ SubscriptionServiceFactory.getInstance().createInterface());
@Override
public PermissionsManager createInterface() {
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerImpl.java b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerImpl.java
index 90b39bea6f..68edb21fd8 100644
--- a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerImpl.java
@@ -13,9 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.itempermissions.dao.impl;
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.ITEM_ID_PROP;
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.ITEM_NAME_PROP;
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_CHANGED;
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_GRANTED;
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_ITEM;
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
@@ -33,158 +44,130 @@ import org.openecomp.sdc.notification.services.SubscriptionService;
import org.openecomp.sdc.versioning.AsdcItemManager;
import org.openecomp.sdc.versioning.types.Item;
-import java.util.*;
-
-import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.*;
-
/**
* Created by ayalaben on 6/18/2017.
*/
public class PermissionsManagerImpl implements PermissionsManager {
- private static final Logger LOGGER = LoggerFactory.getLogger(PermissionsManagerImpl.class);
- private static final String CHANGE_PERMISSIONS = "Change_Item_Permissions";
-
- private PermissionsServices permissionsServices;
- private AsdcItemManager asdcItemManager;
- private NotificationPropagationManager notifier;
- private SubscriptionService subscriptionService;
-
- public PermissionsManagerImpl(PermissionsServices permissionsServices,
- AsdcItemManager asdcItemManager,
- NotificationPropagationManager notificationPropagationManager,
- SubscriptionService subscriptionService) {
- this.permissionsServices = permissionsServices;
- this.asdcItemManager = asdcItemManager;
- this.notifier = notificationPropagationManager;
- this.subscriptionService = subscriptionService;
- }
-
- @Override
- public Collection<ItemPermissionsEntity> listItemPermissions(String itemId) {
-
- return permissionsServices.listItemPermissions(itemId);
- }
-
- @Override
- public Set<String> listUserPermittedItems(String userId, String permission) {
- return permissionsServices.listUserPermittedItems(userId,permission);
- }
-
- @Override
- public void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
- Set<String> removedUsersIds) {
-
- String currentUser =
- SessionContextProviderFactory.getInstance().createInterface().get().getUser().getUserId();
-
- if (!permissionsServices.isAllowed(itemId, currentUser, CHANGE_PERMISSIONS)) {
- throw new CoreException(new ErrorCode.ErrorCodeBuilder()
- .withMessage(Messages.PERMISSIONS_ERROR.getErrorMessage())
- .withId(Messages.PERMISSIONS_ERROR.name())
- .withCategory(ErrorCategory.SECURITY).build());
+ private static final Logger LOGGER = LoggerFactory.getLogger(PermissionsManagerImpl.class);
+ private static final String CHANGE_PERMISSIONS = "Change_Item_Permissions";
+ private PermissionsServices permissionsServices;
+ private AsdcItemManager asdcItemManager;
+ private NotificationPropagationManager notifier;
+ private SubscriptionService subscriptionService;
+
+ public PermissionsManagerImpl(PermissionsServices permissionsServices, AsdcItemManager asdcItemManager,
+ NotificationPropagationManager notificationPropagationManager, SubscriptionService subscriptionService) {
+ this.permissionsServices = permissionsServices;
+ this.asdcItemManager = asdcItemManager;
+ this.notifier = notificationPropagationManager;
+ this.subscriptionService = subscriptionService;
}
- if (permission.equals(PermissionTypes.Owner.name()) ){
- if (addedUsersIds.size() == 1){
- asdcItemManager.updateOwner(itemId,addedUsersIds.iterator().next());
- } else {
- throw new CoreException(new ErrorCode.ErrorCodeBuilder()
- .withMessage(Messages.PERMISSIONS_OWNER_ERROR.getErrorMessage())
- .withId(Messages.PERMISSIONS_OWNER_ERROR.name())
- .withCategory(ErrorCategory.SECURITY).build());
- }
+ @Override
+ public Collection<ItemPermissionsEntity> listItemPermissions(String itemId) {
+ return permissionsServices.listItemPermissions(itemId);
}
- permissionsServices
- .updateItemPermissions(itemId, permission, addedUsersIds, removedUsersIds);
-
- sendNotifications(itemId, permission, addedUsersIds, removedUsersIds, currentUser);
- }
-
- private void sendNotifications(String itemId, String permission, Set<String> addedUsersIds,
- Set<String> removedUsersIds, String userName) {
-
- Item item = asdcItemManager.get(itemId);
- addedUsersIds.forEach(affectedUser -> {
- notifyUser(userName, true, item.getName(), itemId, affectedUser, permission);
- subscriptionService.subscribe(affectedUser, itemId);
- });
- removedUsersIds.forEach(affectedUser -> {
- notifyUser(userName, false, item.getName(), itemId, affectedUser, permission);
- subscriptionService.unsubscribe(affectedUser, itemId);
- });
-
- }
-
- private void notifyUser(String userName, boolean granted, String itemName, String itemId,
- String affectedUser, String permission) {
- Map<String, Object> details = new HashMap<>();
- details.put(PERMISSION_ITEM, permission);
- details.put(ITEM_ID_PROP, itemId);
- details.put(ITEM_NAME_PROP, itemName);
- details.put(PERMISSION_GRANTED, granted);
- details.put(PERMISSION_USER, userName);
- PermissionEvent permissionEvent = new PermissionEvent(PERMISSION_CHANGED, affectedUser,
- details, affectedUser);
-
- try {
- notifier.directNotification(permissionEvent, affectedUser);
- } catch (Exception e) {
- LOGGER.error("Failed to send notification on permission changed for user '" +
- affectedUser + "'");
+ @Override
+ public Set<String> listUserPermittedItems(String userId, String permission) {
+ return permissionsServices.listUserPermittedItems(userId, permission);
}
- }
-
- @Override
- public boolean isAllowed(String itemId, String userId, String action) {
- return permissionsServices.isAllowed(itemId, userId, action);
- }
-
- @Override
- public Optional<String> getUserItemPermission(String itemId, String userId) {
- return permissionsServices.getUserItemPermission(itemId, userId);
- }
-
- @Override
- public void deleteItemPermissions(String itemId) {
- permissionsServices.deleteItemPermissions(itemId);
- }
-
- private class PermissionEvent implements Event {
+ @Override
+ public void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds, Set<String> removedUsersIds) {
+ String currentUser = SessionContextProviderFactory.getInstance().createInterface().get().getUser().getUserId();
+ if (!permissionsServices.isAllowed(itemId, currentUser, CHANGE_PERMISSIONS)) {
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withMessage(Messages.PERMISSIONS_ERROR.getErrorMessage()).withId(Messages.PERMISSIONS_ERROR.name())
+ .withCategory(ErrorCategory.SECURITY).build());
+ }
+ if (permission.equals(PermissionTypes.Owner.name())) {
+ if (addedUsersIds.size() == 1) {
+ asdcItemManager.updateOwner(itemId, addedUsersIds.iterator().next());
+ } else {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder().withMessage(Messages.PERMISSIONS_OWNER_ERROR.getErrorMessage())
+ .withId(Messages.PERMISSIONS_OWNER_ERROR.name()).withCategory(ErrorCategory.SECURITY).build());
+ }
+ }
+ permissionsServices.updateItemPermissions(itemId, permission, addedUsersIds, removedUsersIds);
+ sendNotifications(itemId, permission, addedUsersIds, removedUsersIds, currentUser);
+ }
- private String eventType;
- private String originatorId;
- private Map<String, Object> attributes;
- private String entityId;
+ private void sendNotifications(String itemId, String permission, Set<String> addedUsersIds, Set<String> removedUsersIds, String userName) {
+ Item item = asdcItemManager.get(itemId);
+ addedUsersIds.forEach(affectedUser -> {
+ notifyUser(userName, true, item.getName(), itemId, affectedUser, permission);
+ subscriptionService.subscribe(affectedUser, itemId);
+ });
+ removedUsersIds.forEach(affectedUser -> {
+ notifyUser(userName, false, item.getName(), itemId, affectedUser, permission);
+ subscriptionService.unsubscribe(affectedUser, itemId);
+ });
+ }
- private PermissionEvent(String eventType, String originatorId,
- Map<String, Object> attributes, String entityId) {
- this.eventType = eventType;
- this.originatorId = originatorId;
- this.attributes = attributes;
- this.entityId = entityId;
+ private void notifyUser(String userName, boolean granted, String itemName, String itemId, String affectedUser, String permission) {
+ Map<String, Object> details = new HashMap<>();
+ details.put(PERMISSION_ITEM, permission);
+ details.put(ITEM_ID_PROP, itemId);
+ details.put(ITEM_NAME_PROP, itemName);
+ details.put(PERMISSION_GRANTED, granted);
+ details.put(PERMISSION_USER, userName);
+ PermissionEvent permissionEvent = new PermissionEvent(PERMISSION_CHANGED, affectedUser, details, affectedUser);
+ try {
+ notifier.directNotification(permissionEvent, affectedUser);
+ } catch (Exception e) {
+ LOGGER.error("Failed to send notification on permission changed for user '" + affectedUser + "'");
+ }
}
@Override
- public String getEventType() {
- return eventType;
+ public boolean isAllowed(String itemId, String userId, String action) {
+ return permissionsServices.isAllowed(itemId, userId, action);
}
@Override
- public String getOriginatorId() {
- return originatorId;
+ public Optional<String> getUserItemPermission(String itemId, String userId) {
+ return permissionsServices.getUserItemPermission(itemId, userId);
}
@Override
- public Map<String, Object> getAttributes() {
- return attributes;
+ public void deleteItemPermissions(String itemId) {
+ permissionsServices.deleteItemPermissions(itemId);
}
- @Override
- public String getEntityId() {
- return entityId;
+ private class PermissionEvent implements Event {
+
+ private String eventType;
+ private String originatorId;
+ private Map<String, Object> attributes;
+ private String entityId;
+
+ private PermissionEvent(String eventType, String originatorId, Map<String, Object> attributes, String entityId) {
+ this.eventType = eventType;
+ this.originatorId = originatorId;
+ this.attributes = attributes;
+ this.entityId = entityId;
+ }
+
+ @Override
+ public String getEventType() {
+ return eventType;
+ }
+
+ @Override
+ public String getOriginatorId() {
+ return originatorId;
+ }
+
+ @Override
+ public Map<String, Object> getAttributes() {
+ return attributes;
+ }
+
+ @Override
+ public String getEntityId() {
+ return entityId;
+ }
}
- }
}
diff --git a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/AuthenticationCookie.java b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/AuthenticationCookie.java
index 56a4965381..4627fcee14 100644
--- a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/AuthenticationCookie.java
+++ b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/AuthenticationCookie.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,22 +17,21 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.securityutil;
import java.util.Set;
-
-public class AuthenticationCookie {
+public class AuthenticationCookie {
private String userID;
private Set<String> roles;
private long maxSessionTime;
private long currentSessionTime;
- public AuthenticationCookie(){ }
+ public AuthenticationCookie() {
+ }
- public AuthenticationCookie(AuthenticationCookie authenticationCookie){
+ public AuthenticationCookie(AuthenticationCookie authenticationCookie) {
this.userID = authenticationCookie.userID;
this.roles = authenticationCookie.roles;
this.maxSessionTime = authenticationCookie.maxSessionTime;
@@ -41,10 +40,11 @@ public class AuthenticationCookie {
/**
* Create new cookie with max_session_time and current_session_time started with same value
+ *
* @param userId
*/
public AuthenticationCookie(String userId) {
- this.userID =userId;
+ this.userID = userId;
long currentTimeMilliSec = System.currentTimeMillis();
this.maxSessionTime = currentTimeMilliSec;
this.currentSessionTime = currentTimeMilliSec;
@@ -74,7 +74,6 @@ public class AuthenticationCookie {
this.maxSessionTime = maxSessionTime;
}
-
public long getCurrentSessionTime() {
return currentSessionTime;
}
@@ -85,14 +84,22 @@ public class AuthenticationCookie {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof AuthenticationCookie)) return false;
-
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof AuthenticationCookie)) {
+ return false;
+ }
AuthenticationCookie that = (AuthenticationCookie) o;
-
- if (getMaxSessionTime() != that.getMaxSessionTime()) return false;
- if (getCurrentSessionTime() != that.getCurrentSessionTime()) return false;
- if (getUserID() != null ? !getUserID().equals(that.getUserID()) : that.getUserID() != null) return false;
+ if (getMaxSessionTime() != that.getMaxSessionTime()) {
+ return false;
+ }
+ if (getCurrentSessionTime() != that.getCurrentSessionTime()) {
+ return false;
+ }
+ if (getUserID() != null ? !getUserID().equals(that.getUserID()) : that.getUserID() != null) {
+ return false;
+ }
return getRoles() != null ? getRoles().containsAll(that.getRoles()) : that.getRoles() == null;
}
@@ -107,11 +114,7 @@ public class AuthenticationCookie {
@Override
public String toString() {
- return "AuthenticationCookie{" +
- "userID='" + userID + '\'' +
- ", roles=" + roles +
- ", maxSessionTime=" + maxSessionTime +
- ", currentSessionTime=" + currentSessionTime +
- '}';
+ return "AuthenticationCookie{" + "userID='" + userID + '\'' + ", roles=" + roles + ", maxSessionTime=" + maxSessionTime
+ + ", currentSessionTime=" + currentSessionTime + '}';
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/AuthenticationCookieUtils.java b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/AuthenticationCookieUtils.java
index f0a33da8a7..d71c8593f3 100644
--- a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/AuthenticationCookieUtils.java
+++ b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/AuthenticationCookieUtils.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,16 +17,14 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.securityutil;
+import java.io.IOException;
+import javax.servlet.http.Cookie;
import org.openecomp.sdc.securityutil.filters.SessionValidationFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.servlet.http.Cookie;
-import java.io.IOException;
-
public class AuthenticationCookieUtils {
private static final Logger log = LoggerFactory.getLogger(SessionValidationFilter.class.getName());
@@ -43,10 +41,12 @@ public class AuthenticationCookieUtils {
* @throws CipherUtilException
* @throws IOException
*/
- public static Cookie updateSessionTime(Cookie cookie, ISessionValidationFilterConfiguration filterConfiguration) throws CipherUtilException, IOException {
+ public static Cookie updateSessionTime(Cookie cookie, ISessionValidationFilterConfiguration filterConfiguration)
+ throws CipherUtilException, IOException {
AuthenticationCookie authenticationCookie = getAuthenticationCookie(cookie, filterConfiguration);
long newTime = System.currentTimeMillis();
- log.debug("SessionValidationFilter: Going to set new session time in cookie, old value: {}, new value: {}", authenticationCookie.getCurrentSessionTime(), newTime);
+ log.debug("SessionValidationFilter: Going to set new session time in cookie, old value: {}, new value: {}",
+ authenticationCookie.getCurrentSessionTime(), newTime);
authenticationCookie.setCurrentSessionTime(newTime);
String encryptedCookie = getEncryptedCookie(authenticationCookie, filterConfiguration);
return createUpdatedCookie(cookie, encryptedCookie, filterConfiguration);
@@ -54,13 +54,14 @@ public class AuthenticationCookieUtils {
/**
* Create new Cookie object with same attributes as original cookie
+ *
* @param cookie
* @param encryptedCookie
* @param cookieConfiguration
* @return
*/
public static Cookie createUpdatedCookie(Cookie cookie, String encryptedCookie, ISessionValidationCookieConfiguration cookieConfiguration) {
- Cookie updatedCookie = new Cookie(cookie.getName(), encryptedCookie );
+ Cookie updatedCookie = new Cookie(cookie.getName(), encryptedCookie);
updatedCookie.setSecure(true);
updatedCookie.setPath(cookieConfiguration.getCookiePath());
updatedCookie.setDomain(cookieConfiguration.getCookieDomain());
@@ -77,7 +78,8 @@ public class AuthenticationCookieUtils {
* @throws IOException
* @throws CipherUtilException
*/
- public static String getEncryptedCookie(AuthenticationCookie authenticationCookie, ISessionValidationFilterConfiguration filterConfiguration) throws IOException, CipherUtilException {
+ public static String getEncryptedCookie(AuthenticationCookie authenticationCookie, ISessionValidationFilterConfiguration filterConfiguration)
+ throws IOException, CipherUtilException {
String changedCookieJson = RepresentationUtils.toRepresentation(authenticationCookie);
return CipherUtil.encryptPKC(changedCookieJson, filterConfiguration.getSecurityKey());
}
@@ -90,7 +92,8 @@ public class AuthenticationCookieUtils {
* @return
* @throws CipherUtilException
*/
- public static AuthenticationCookie getAuthenticationCookie(Cookie cookie, ISessionValidationFilterConfiguration filterConfiguration) throws CipherUtilException {
+ public static AuthenticationCookie getAuthenticationCookie(Cookie cookie, ISessionValidationFilterConfiguration filterConfiguration)
+ throws CipherUtilException {
String originalCookieJson = CipherUtil.decryptPKC(cookie.getValue(), filterConfiguration.getSecurityKey());
return RepresentationUtils.fromRepresentation(originalCookieJson, AuthenticationCookie.class);
}
@@ -108,7 +111,8 @@ public class AuthenticationCookieUtils {
long sessionExpirationDate = authenticationCookie.getMaxSessionTime() + filterConfiguration.getMaxSessionTimeOut();
long sessionTime = authenticationCookie.getCurrentSessionTime();
long currentTime = System.currentTimeMillis();
- log.debug("SessionValidationFilter: Checking if session expired: session time: {}, expiration time: {}, current time: {}", sessionTime, sessionExpirationDate, currentTime);
+ log.debug("SessionValidationFilter: Checking if session expired: session time: {}, expiration time: {}, current time: {}", sessionTime,
+ sessionExpirationDate, currentTime);
return currentTime > sessionExpirationDate || isSessionIdle(sessionTime, currentTime, filterConfiguration);
}
@@ -123,8 +127,8 @@ public class AuthenticationCookieUtils {
private static boolean isSessionIdle(long sessionTimeValue, long currentTime, ISessionValidationFilterConfiguration filterConfiguration) {
long currentIdleTime = currentTime - sessionTimeValue;
long maxIdleTime = filterConfiguration.getSessionIdleTimeOut();
- log.debug("SessionValidationFilter: Checking if session idle: session time: {}, current idle time: {}, max idle time: {}", currentTime, currentIdleTime, maxIdleTime);
+ log.debug("SessionValidationFilter: Checking if session idle: session time: {}, current idle time: {}, max idle time: {}", currentTime,
+ currentIdleTime, maxIdleTime);
return currentIdleTime >= maxIdleTime;
}
-
}
diff --git a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/CipherUtil.java b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/CipherUtil.java
index 71ac6151f7..d69471e398 100644
--- a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/CipherUtil.java
+++ b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/CipherUtil.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.securityutil;
import java.security.SecureRandom;
@@ -31,18 +30,17 @@ import org.slf4j.LoggerFactory;
public class CipherUtil {
- private static Logger log = LoggerFactory.getLogger(CipherUtil.class.getName());
+ public static final int GCM_TAG_LENGTH = 16;
+ public static final int GCM_IV_LENGTH = 12;
private static final String ALGORITHM = "AES";
private static final String ALGORITHM_DETAILS = ALGORITHM + "/GCM/NoPadding";
private static final String CIPHER_PROVIDER = "SunJCE";
-
- public static final int GCM_TAG_LENGTH = 16;
- public static final int GCM_IV_LENGTH = 12;
-
private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
private static final String ALGORITHM_NAME = "SHA1PRNG";
+ private static Logger log = LoggerFactory.getLogger(CipherUtil.class.getName());
- private CipherUtil() {}
+ private CipherUtil() {
+ }
/**
* Encrypt the text using the secret key in key.properties file
@@ -59,11 +57,9 @@ public class CipherUtil {
cipher = Cipher.getInstance(ALGORITHM_DETAILS, CIPHER_PROVIDER);
SecureRandom secureRandom = SecureRandom.getInstance(ALGORITHM_NAME);
secureRandom.nextBytes(iv);
- GCMParameterSpec spec =
- new GCMParameterSpec(GCM_TAG_LENGTH * java.lang.Byte.SIZE, iv);
+ GCMParameterSpec spec = new GCMParameterSpec(GCM_TAG_LENGTH * java.lang.Byte.SIZE, iv);
cipher.init(Cipher.ENCRYPT_MODE, getSecretKeySpec(base64key), spec);
finalByte = cipher.doFinal(value.getBytes());
-
} catch (Exception ex) {
log.error("encrypt failed", ex);
throw new CipherUtilException(ex);
@@ -74,12 +70,10 @@ public class CipherUtil {
/**
* Decrypts the text using the secret key in key.properties file.
*
- * @param message The encrypted string that must be decrypted using the ONAP Portal Encryption
- * Key
+ * @param message The encrypted string that must be decrypted using the ONAP Portal Encryption Key
* @return The String decrypted
* @throws CipherUtilException if any decryption step fails
*/
-
public static String decryptPKC(String message, String base64key) throws CipherUtilException {
byte[] encryptedMessage = Base64.decodeBase64(message);
Cipher cipher;
@@ -87,12 +81,10 @@ public class CipherUtil {
try {
cipher = Cipher.getInstance(ALGORITHM_DETAILS, CIPHER_PROVIDER);
byte[] initVector = Arrays.copyOfRange(encryptedMessage, 0, GCM_IV_LENGTH);
- GCMParameterSpec spec =
- new GCMParameterSpec(GCM_TAG_LENGTH * java.lang.Byte.SIZE, initVector);
+ GCMParameterSpec spec = new GCMParameterSpec(GCM_TAG_LENGTH * java.lang.Byte.SIZE, initVector);
byte[] realData = subarray(encryptedMessage, GCM_IV_LENGTH, encryptedMessage.length);
cipher.init(Cipher.DECRYPT_MODE, getSecretKeySpec(base64key), spec);
decrypted = cipher.doFinal(realData);
-
} catch (Exception ex) {
log.error("decrypt failed", ex);
throw new CipherUtilException(ex);
@@ -129,11 +121,9 @@ public class CipherUtil {
if (startIndexInclusive < 0) {
startIndexInclusive = 0;
}
-
if (endIndexExclusive > array.length) {
endIndexExclusive = array.length;
}
-
int newSize = endIndexExclusive - startIndexInclusive;
if (newSize <= 0) {
return EMPTY_BYTE_ARRAY;
diff --git a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/CipherUtilException.java b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/CipherUtilException.java
index 5b1a602b58..9e202de3c4 100644
--- a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/CipherUtilException.java
+++ b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/CipherUtilException.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -42,5 +42,4 @@ public class CipherUtilException extends Exception {
public CipherUtilException(Throwable cause) {
super(cause);
}
-
}
diff --git a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/ISessionValidationCookieConfiguration.java b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/ISessionValidationCookieConfiguration.java
index d684238db1..5371d0174f 100644
--- a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/ISessionValidationCookieConfiguration.java
+++ b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/ISessionValidationCookieConfiguration.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,16 +17,18 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.securityutil;
/**
- * Configuration for Cookie object , have to be same over all components of application
+ * Configuration for Cookie object , have to be same over all components of application
*/
public interface ISessionValidationCookieConfiguration {
String getCookieName();
+
String getCookieDomain();
+
String getCookiePath();
+
boolean isCookieHttpOnly();
}
diff --git a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/ISessionValidationFilterConfiguration.java b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/ISessionValidationFilterConfiguration.java
index ccae39423e..25e5683ebf 100644
--- a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/ISessionValidationFilterConfiguration.java
+++ b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/ISessionValidationFilterConfiguration.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.securityutil;
import java.util.List;
@@ -25,9 +24,12 @@ import java.util.List;
public interface ISessionValidationFilterConfiguration extends ISessionValidationCookieConfiguration {
String getSecurityKey();
+
long getMaxSessionTimeOut();
+
long getSessionIdleTimeOut(); // max idle time for session
+
String getRedirectURL();
- List<String> getExcludedUrls(); // comma separated URLs, like this "/config,/configmgr,/rest,/kibanaProxy"
-}
+ List<String> getExcludedUrls(); // comma separated URLs, like this "/config,/configmgr,/rest,/kibanaProxy"
+}
diff --git a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/Passwords.java b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/Passwords.java
index e10bd81d0f..bbaece44a2 100644
--- a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/Passwords.java
+++ b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/Passwords.java
@@ -7,9 +7,9 @@ package org.openecomp.sdc.securityutil;/*-
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,170 +18,171 @@ package org.openecomp.sdc.securityutil;/*-
* ============LICENSE_END=========================================================
*/
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Random;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class Passwords {
- private static Logger log = LoggerFactory.getLogger( Passwords.class.getName());
- private static final Random RANDOM = new SecureRandom();
- private static final int SALT = 0;
- private static final int HASH = 1;
- private static final String HASH_ALGORITHM = "SHA-256";
-
- /**
- * static utility class
- */
- private Passwords() {
- }
-
- /**
- * the method calculates a hash with a generated salt for the given password
- *
- * @param password
- * @return a "salt:hash" value
- */
- public static String hashPassword(String password) {
- if (password!=null){
- byte[] salt = getNextSalt();
- byte byteData[] = hash(salt, password.getBytes());
- if (byteData != null) {
- return toHex(salt) + ":" + toHex(byteData);
- }
- }
- return null;
- }
-
- /**
- * the method checks if the given password matches the calculated hash
- *
- * @param password
- * @param expectedHash
- * @return
- */
- public static boolean isExpectedPassword(String password, String expectedHash) {
- if (password==null && expectedHash==null)
- return true;
- if (password==null || expectedHash==null) //iff exactly 1 is null
- return false;
- if (!expectedHash.contains(":")){
- log.error("invalid password expecting hash at the prefix of the password (ex. e0277df331f4ff8f74752ac4a8fbe03b:6dfbad308cdf53c9ff2ee2dca811ee92f1b359586b33027580e2ff92578edbd0)\n" +
- "\t\t\t");
- return false;
- }
- String[] params = expectedHash.split(":");
- return isExpectedPassword(password, params[SALT], params[HASH]);
- }
-
- /**
- * the method checks if the given password matches the calculated hash
- *
- * @param password
- * @param salt
- * @param hash
- * the hash generated using the salt
- * @return true if the password matched the hash
- */
- public static boolean isExpectedPassword(String password, String salt, String hash) {
- if ( password == null && hash == null )
- return true;
- if ( salt == null ){
- log.error("salt must be initialized");
- return false;
- }
- //unintialized params
- if ( password == null || hash == null )
- return false;
- byte[] saltBytes = fromHex(salt);
- byte[] hashBytes = fromHex(hash);
-
- byte byteData[] = hash(saltBytes, password.getBytes());
- if (byteData != null) {
- return Arrays.equals(byteData, hashBytes);
- }
- return false;
- }
-
- public static void main(String[] args) {
- if (args.length > 1 || args.length > 0) {
- System.out.println("[" + hashPassword(args[0]) + "]");
- } else {
- System.out.println("no passward passed.");
- }
-
- }
-
- /**
- * Returns a random salt to be used to hash a password.
- *
- * @return a 16 bytes random salt
- */
- private static byte[] getNextSalt() {
- byte[] salt = new byte[16];
- RANDOM.nextBytes(salt);
- return salt;
- }
-
- /**
- * hase's the salt and value using the chosen algorithm
- *
- * @param salt
- * @param password
- * @return an array of bytes resulting from the hash
- */
- private static byte[] hash(byte[] salt, byte[] password) {
- MessageDigest md;
- byte[] byteData = null;
- try {
- md = MessageDigest.getInstance(HASH_ALGORITHM);
- md.update(salt);
- md.update(password);
- byteData = md.digest();
- } catch (NoSuchAlgorithmException e) {
- System.out.println("invalid algorithm name");
- }
- return byteData;
- }
-
- /**
- * Converts a string of hexadecimal characters into a byte array.
- *
- * @param hex
- * the hex string
- * @return the hex string decoded into a byte array
- */
- private static byte[] fromHex(String hex) {
- if ( hex == null )
- return null;
- byte[] binary = new byte[hex.length() / 2];
- for (int i = 0; i < binary.length; i++) {
- binary[i] = (byte) Integer.parseInt(hex.substring(2 * i, 2 * i + 2), 16);
- }
- return binary;
- }
-
- /**
- * Converts a byte array into a hexadecimal string.
- *
- * @param array
- * the byte array to convert
- * @return a length*2 character string encoding the byte array
- */
- private static String toHex(byte[] array) {
- BigInteger bi = new BigInteger(1, array);
- String hex = bi.toString(16);
- int paddingLength = (array.length * 2) - hex.length();
- if (paddingLength > 0)
- return String.format("%0" + paddingLength + "d", 0) + hex;
- else
- return hex;
- }
+ private static final Random RANDOM = new SecureRandom();
+ private static final int SALT = 0;
+ private static final int HASH = 1;
+ private static final String HASH_ALGORITHM = "SHA-256";
+ private static Logger log = LoggerFactory.getLogger(Passwords.class.getName());
+
+ /**
+ * static utility class
+ */
+ private Passwords() {
+ }
+
+ /**
+ * the method calculates a hash with a generated salt for the given password
+ *
+ * @param password
+ * @return a "salt:hash" value
+ */
+ public static String hashPassword(String password) {
+ if (password != null) {
+ byte[] salt = getNextSalt();
+ byte byteData[] = hash(salt, password.getBytes());
+ if (byteData != null) {
+ return toHex(salt) + ":" + toHex(byteData);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * the method checks if the given password matches the calculated hash
+ *
+ * @param password
+ * @param expectedHash
+ * @return
+ */
+ public static boolean isExpectedPassword(String password, String expectedHash) {
+ if (password == null && expectedHash == null) {
+ return true;
+ }
+ if (password == null || expectedHash == null) //iff exactly 1 is null
+ {
+ return false;
+ }
+ if (!expectedHash.contains(":")) {
+ log.error(
+ "invalid password expecting hash at the prefix of the password (ex. e0277df331f4ff8f74752ac4a8fbe03b:6dfbad308cdf53c9ff2ee2dca811ee92f1b359586b33027580e2ff92578edbd0)\n"
+ + "\t\t\t");
+ return false;
+ }
+ String[] params = expectedHash.split(":");
+ return isExpectedPassword(password, params[SALT], params[HASH]);
+ }
+
+ /**
+ * the method checks if the given password matches the calculated hash
+ *
+ * @param password
+ * @param salt
+ * @param hash the hash generated using the salt
+ * @return true if the password matched the hash
+ */
+ public static boolean isExpectedPassword(String password, String salt, String hash) {
+ if (password == null && hash == null) {
+ return true;
+ }
+ if (salt == null) {
+ log.error("salt must be initialized");
+ return false;
+ }
+ //unintialized params
+ if (password == null || hash == null) {
+ return false;
+ }
+ byte[] saltBytes = fromHex(salt);
+ byte[] hashBytes = fromHex(hash);
+ byte byteData[] = hash(saltBytes, password.getBytes());
+ if (byteData != null) {
+ return Arrays.equals(byteData, hashBytes);
+ }
+ return false;
+ }
+
+ public static void main(String[] args) {
+ if (args.length > 1 || args.length > 0) {
+ System.out.println("[" + hashPassword(args[0]) + "]");
+ } else {
+ System.out.println("no passward passed.");
+ }
+ }
+
+ /**
+ * Returns a random salt to be used to hash a password.
+ *
+ * @return a 16 bytes random salt
+ */
+ private static byte[] getNextSalt() {
+ byte[] salt = new byte[16];
+ RANDOM.nextBytes(salt);
+ return salt;
+ }
+
+ /**
+ * hase's the salt and value using the chosen algorithm
+ *
+ * @param salt
+ * @param password
+ * @return an array of bytes resulting from the hash
+ */
+ private static byte[] hash(byte[] salt, byte[] password) {
+ MessageDigest md;
+ byte[] byteData = null;
+ try {
+ md = MessageDigest.getInstance(HASH_ALGORITHM);
+ md.update(salt);
+ md.update(password);
+ byteData = md.digest();
+ } catch (NoSuchAlgorithmException e) {
+ System.out.println("invalid algorithm name");
+ }
+ return byteData;
+ }
+
+ /**
+ * Converts a string of hexadecimal characters into a byte array.
+ *
+ * @param hex the hex string
+ * @return the hex string decoded into a byte array
+ */
+ private static byte[] fromHex(String hex) {
+ if (hex == null) {
+ return null;
+ }
+ byte[] binary = new byte[hex.length() / 2];
+ for (int i = 0; i < binary.length; i++) {
+ binary[i] = (byte) Integer.parseInt(hex.substring(2 * i, 2 * i + 2), 16);
+ }
+ return binary;
+ }
+
+ /**
+ * Converts a byte array into a hexadecimal string.
+ *
+ * @param array the byte array to convert
+ * @return a length*2 character string encoding the byte array
+ */
+ private static String toHex(byte[] array) {
+ BigInteger bi = new BigInteger(1, array);
+ String hex = bi.toString(16);
+ int paddingLength = (array.length * 2) - hex.length();
+ if (paddingLength > 0) {
+ return String.format("%0" + paddingLength + "d", 0) + hex;
+ } else {
+ return hex;
+ }
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/RepresentationUtils.java b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/RepresentationUtils.java
index 7fece5fda0..f47e61213e 100644
--- a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/RepresentationUtils.java
+++ b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/RepresentationUtils.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,18 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.securityutil;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
+import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-
public class RepresentationUtils {
private static final Logger log = LoggerFactory.getLogger(RepresentationUtils.class.getName());
@@ -41,7 +39,6 @@ public class RepresentationUtils {
* @throws IOException
*/
public static <T> String toRepresentation(T elementToRepresent) throws IOException {
-
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
@@ -67,7 +64,6 @@ public class RepresentationUtils {
} catch (Exception e) {
log.error("Error when parsing JSON of object of type {}", clazz.getSimpleName(), e);
} // return null in case of exception
-
return object;
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/FilterServletOutputStream.java b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/FilterServletOutputStream.java
index 30414e38b7..c5dbabfb30 100644
--- a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/FilterServletOutputStream.java
+++ b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/FilterServletOutputStream.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,14 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.securityutil.filters;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.WriteListener;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.WriteListener;
public class FilterServletOutputStream extends ServletOutputStream {
@@ -38,12 +37,12 @@ public class FilterServletOutputStream extends ServletOutputStream {
stream.write(b);
}
- public void write(byte[] b) throws IOException {
+ public void write(byte[] b) throws IOException {
stream.write(b);
}
- public void write(byte[] b, int off, int len) throws IOException {
- stream.write(b,off,len);
+ public void write(byte[] b, int off, int len) throws IOException {
+ stream.write(b, off, len);
}
@Override
@@ -53,6 +52,5 @@ public class FilterServletOutputStream extends ServletOutputStream {
@Override
public void setWriteListener(WriteListener writeListener) {
-
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/ResponceWrapper.java b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/ResponceWrapper.java
index dd4576e811..5ef821e542 100644
--- a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/ResponceWrapper.java
+++ b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/ResponceWrapper.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,19 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.securityutil.filters;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
import javax.servlet.ServletOutputStream;
-import javax.servlet.WriteListener;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
-import java.io.ByteArrayOutputStream;
-import java.io.CharArrayWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
public class ResponceWrapper extends HttpServletResponseWrapper {
+
private ByteArrayOutputStream output;
private int contentLength;
private String contentType;
@@ -51,23 +48,21 @@ public class ResponceWrapper extends HttpServletResponseWrapper {
return new PrintWriter(getOutputStream(), true);
}
+ public int getContentLength() {
+ return contentLength;
+ }
+
public void setContentLength(int length) {
this.contentLength = length;
super.setContentLength(length);
}
- public int getContentLength() {
- return contentLength;
+ public String getContentType() {
+ return contentType;
}
public void setContentType(String type) {
this.contentType = type;
super.setContentType(type);
}
-
-
- public String getContentType() {
- return contentType;
-
- }
}
diff --git a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/SampleFilter.java b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/SampleFilter.java
index e54a08af6f..81cc4cd49d 100644
--- a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/SampleFilter.java
+++ b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/SampleFilter.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,29 +17,39 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.securityutil.filters;
-
-import org.openecomp.sdc.securityutil.ISessionValidationFilterConfiguration;
-
-import javax.servlet.http.Cookie;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import javax.servlet.http.Cookie;
+import org.openecomp.sdc.securityutil.ISessionValidationFilterConfiguration;
public class SampleFilter extends SessionValidationFilter {
+ @Override
+ public ISessionValidationFilterConfiguration getFilterConfiguration() {
+ return Configuration.getInstance();
+ }
+
+ @Override
+ protected Cookie addRoleToCookie(Cookie updatedCookie) {
+ return updatedCookie;
+ }
+
+ @Override
+ protected boolean isRoleValid(Cookie cookie) {
+ return true;
+ }
+
private static class Configuration implements ISessionValidationFilterConfiguration {
private static Configuration instance;
-
private String securityKey;
private long maxSessionTimeOut;
private long sessionIdleTimeOut;
private String redirectURL;
private List<String> excludedUrls;
-
private String cookieName;
private String cookieDomain;
private String cookiePath;
@@ -48,40 +58,19 @@ public class SampleFilter extends SessionValidationFilter {
private Configuration() {
//security key should be exactly 16 characters long clear text and then encoded to base64
this.securityKey = "AGLDdG4D04BKm2IxIWEr8o==";
- this.maxSessionTimeOut = 24L*60L*60L*1000L;
- this.sessionIdleTimeOut = 60L*60L*1000L;
+ this.maxSessionTimeOut = 24L * 60L * 60L * 1000L;
+ this.sessionIdleTimeOut = 60L * 60L * 1000L;
this.redirectURL = "https://www.e-access.att.com/ecomp_portal_ist/ecompportal/process_csp";
- this.excludedUrls = new ArrayList<>(Arrays.asList("/config","/configmgr","/rest","/kibanaProxy","/healthcheck","/upload.*"));
-
+ this.excludedUrls = new ArrayList<>(Arrays.asList("/config", "/configmgr", "/rest", "/kibanaProxy", "/healthcheck", "/upload.*"));
this.cookieName = "kuku";
this.cookieDomain = "";
this.cookiePath = "/";
this.isCookieHttpOnly = true;
}
- public void setSecurityKey(String securityKey) {
- this.securityKey = securityKey;
- }
-
- public void setMaxSessionTimeOut(long maxSessionTimeOut) {
- this.maxSessionTimeOut = maxSessionTimeOut;
- }
-
- public void setCookieName(String cookieName) {
- this.cookieName = cookieName;
- }
-
- public void setRedirectURL(String redirectURL) {
- this.redirectURL = redirectURL;
- }
-
- public void setExcludedUrls(List<String> excludedUrls) {
- this.excludedUrls = excludedUrls;
- }
-
- public static Configuration getInstance(){
- if (instance == null ){
- instance = new Configuration();
+ public static Configuration getInstance() {
+ if (instance == null) {
+ instance = new Configuration();
}
return instance;
}
@@ -91,11 +80,19 @@ public class SampleFilter extends SessionValidationFilter {
return securityKey;
}
+ public void setSecurityKey(String securityKey) {
+ this.securityKey = securityKey;
+ }
+
@Override
public long getMaxSessionTimeOut() {
return maxSessionTimeOut;
}
+ public void setMaxSessionTimeOut(long maxSessionTimeOut) {
+ this.maxSessionTimeOut = maxSessionTimeOut;
+ }
+
@Override
public long getSessionIdleTimeOut() {
return sessionIdleTimeOut;
@@ -106,6 +103,10 @@ public class SampleFilter extends SessionValidationFilter {
return cookieName;
}
+ public void setCookieName(String cookieName) {
+ this.cookieName = cookieName;
+ }
+
@Override
public String getCookieDomain() {
return cookieDomain;
@@ -126,27 +127,17 @@ public class SampleFilter extends SessionValidationFilter {
return redirectURL;
}
+ public void setRedirectURL(String redirectURL) {
+ this.redirectURL = redirectURL;
+ }
+
@Override
public List<String> getExcludedUrls() {
return excludedUrls;
}
- }
-
- @Override
- public ISessionValidationFilterConfiguration getFilterConfiguration() {
- return Configuration.getInstance();
- }
-
- @Override
- protected Cookie addRoleToCookie(Cookie updatedCookie) {
- return updatedCookie;
- }
- @Override
- protected boolean isRoleValid(Cookie cookie) {
- return true;
+ public void setExcludedUrls(List<String> excludedUrls) {
+ this.excludedUrls = excludedUrls;
+ }
}
-
}
-
-
diff --git a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/SessionValidationFilter.java b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/SessionValidationFilter.java
index de235bff89..cf24874f38 100644
--- a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/SessionValidationFilter.java
+++ b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/filters/SessionValidationFilter.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,18 +17,14 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.securityutil.filters;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.openecomp.sdc.securityutil.AuthenticationCookieUtils;
-import org.openecomp.sdc.securityutil.CipherUtilException;
-import org.openecomp.sdc.securityutil.ISessionValidationFilterConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.apache.commons.lang.StringUtils;
-
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -38,33 +34,70 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
+import org.apache.commons.lang.StringUtils;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.openecomp.sdc.securityutil.AuthenticationCookieUtils;
+import org.openecomp.sdc.securityutil.CipherUtilException;
+import org.openecomp.sdc.securityutil.ISessionValidationFilterConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
public abstract class SessionValidationFilter implements Filter {
- private static final Logger log = LoggerFactory.getLogger(SessionValidationFilter.class.getName());
- private ISessionValidationFilterConfiguration filterConfiguration;
- private List<String> excludedUrls;
+ private static final Logger log = LoggerFactory.getLogger(SessionValidationFilter.class.getName());
private static final String REQUEST_ID = ONAPLogConstants.MDCs.REQUEST_ID;
private static final String ONAP_REQUEST_ID_HEADER = ONAPLogConstants.Headers.REQUEST_ID;
private static final String REQUEST_ID_HEADER = "X-RequestID";
private static final String TRANSACTION_ID_HEADER = "X-TransactionId";
private static final String ECOMP_REQUEST_ID_HEADER = "X-ECOMP-RequestID";
-
private static final String PARTNER_NAME = ONAPLogConstants.MDCs.PARTNER_NAME;
private static final String USER_ID_HEADER = "USER_ID";
private static final String ONAP_PARTNER_NAME_HEADER = ONAPLogConstants.Headers.PARTNER_NAME;
private static final String USER_AGENT_HEADER = "User-Agent";
private static final String UNKNOWN = "UNKNOWN";
+ private ISessionValidationFilterConfiguration filterConfiguration;
+ private List<String> excludedUrls;
+ public static void fillMDCFromHeaders(HttpServletRequest httpServletRequest) {
+ fillRequestIdFromHeader(httpServletRequest);
+ fillPartnerNameFromHeader(httpServletRequest);
+ }
+
+ private static void fillRequestIdFromHeader(HttpServletRequest httpServletRequest) {
+ if (MDC.get(REQUEST_ID) == null) {
+ if (StringUtils.isNotEmpty(httpServletRequest.getHeader(ONAP_REQUEST_ID_HEADER))) {
+ MDC.put(REQUEST_ID, httpServletRequest.getHeader(ONAP_REQUEST_ID_HEADER));
+ } else if (StringUtils.isNotEmpty(httpServletRequest.getHeader(REQUEST_ID_HEADER))) {
+ MDC.put(REQUEST_ID, httpServletRequest.getHeader(REQUEST_ID_HEADER));
+ } else if (StringUtils.isNotEmpty(httpServletRequest.getHeader(TRANSACTION_ID_HEADER))) {
+ MDC.put(REQUEST_ID, httpServletRequest.getHeader(TRANSACTION_ID_HEADER));
+ } else if (StringUtils.isNotEmpty(httpServletRequest.getHeader(ECOMP_REQUEST_ID_HEADER))) {
+ MDC.put(REQUEST_ID, httpServletRequest.getHeader(ECOMP_REQUEST_ID_HEADER));
+ } else {
+ MDC.put(REQUEST_ID, UUID.randomUUID().toString());
+ }
+ }
+ }
+
+ private static void fillPartnerNameFromHeader(HttpServletRequest httpServletRequest) {
+ if (MDC.get(PARTNER_NAME) == null) {
+ if (StringUtils.isNotEmpty(httpServletRequest.getHeader(USER_ID_HEADER))) {
+ MDC.put(PARTNER_NAME, httpServletRequest.getHeader(USER_ID_HEADER));
+ } else if (StringUtils.isNotEmpty(httpServletRequest.getHeader(ONAP_PARTNER_NAME_HEADER))) {
+ MDC.put(PARTNER_NAME, httpServletRequest.getHeader(ONAP_PARTNER_NAME_HEADER));
+ } else if (StringUtils.isNotEmpty(httpServletRequest.getHeader(USER_AGENT_HEADER))) {
+ MDC.put(PARTNER_NAME, httpServletRequest.getHeader(USER_AGENT_HEADER));
+ } else {
+ MDC.put(PARTNER_NAME, UNKNOWN);
+ }
+ }
+ }
public abstract ISessionValidationFilterConfiguration getFilterConfiguration();
+
protected abstract Cookie addRoleToCookie(Cookie updatedCookie);
+
protected abstract boolean isRoleValid(Cookie cookie);
@Override
@@ -74,52 +107,52 @@ public abstract class SessionValidationFilter implements Filter {
}
@Override
- public final void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
+ public final void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
+ throws IOException, ServletException {
final HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
final HttpServletResponse httpResponse = (HttpServletResponse) servletResponse;
-
long startTime = System.nanoTime();
fillMDCFromHeaders(httpRequest);
log.debug("SessionValidationFilter: Validation started, received request with URL {}", httpRequest.getRequestURL());
-
// request preprocessing
boolean isContinueProcessing = preProcessingRequest(servletRequest, servletResponse, filterChain, httpRequest, httpResponse, startTime);
List<Cookie> cookies = null;
Cookie extractedCookie = null;
-
// request processing
if (isContinueProcessing) {
cookies = extractAuthenticationCookies(httpRequest.getCookies());
extractedCookie = cookies.get(0);
isContinueProcessing = processRequest(httpRequest, httpResponse, extractedCookie);
}
-
// response processing
- if(isContinueProcessing){
- log.debug("SessionValidationFilter: Cookie from request {} is valid, passing request to session extension ...", httpRequest.getRequestURL());
+ if (isContinueProcessing) {
+ log.debug("SessionValidationFilter: Cookie from request {} is valid, passing request to session extension ...",
+ httpRequest.getRequestURL());
Cookie updatedCookie = processResponse(extractedCookie);
cleanResponceFromLeftoverCookies(httpResponse, cookies);
log.debug("SessionValidationFilter: request {} passed all validations, passing request to endpoint ...", httpRequest.getRequestURL());
httpResponse.addCookie(updatedCookie);
long durationSec = TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime);
long durationMil = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
- log.debug("SessionValidationFilter: Validation ended, running time for URL {} is: {} seconds {} miliseconds", httpRequest.getPathInfo(), durationSec, durationMil);
+ log.debug("SessionValidationFilter: Validation ended, running time for URL {} is: {} seconds {} miliseconds", httpRequest.getPathInfo(),
+ durationSec, durationMil);
filterChain.doFilter(servletRequest, httpResponse);
}
}
-
- private boolean preProcessingRequest(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain, HttpServletRequest httpRequest, HttpServletResponse httpResponse, long startTime) throws IOException, ServletException {
-
+ private boolean preProcessingRequest(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain,
+ HttpServletRequest httpRequest, HttpServletResponse httpResponse, long startTime)
+ throws IOException, ServletException {
boolean isPreProcessingSucceeded = true;
if (isUrlFromWhiteList(httpRequest)) {
- log.debug("SessionValidationFilter: URL {} excluded from access validation , passing request to endpoint ... ", httpRequest.getRequestURL());
+ log.debug("SessionValidationFilter: URL {} excluded from access validation , passing request to endpoint ... ",
+ httpRequest.getRequestURL());
long durationSec = TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime);
long durationMil = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
- log.debug("SessionValidationFilter: Validation ended, running time for URL {} is: {} seconds {} miliseconds", httpRequest.getPathInfo(), durationSec, durationMil);
+ log.debug("SessionValidationFilter: Validation ended, running time for URL {} is: {} seconds {} miliseconds", httpRequest.getPathInfo(),
+ durationSec, durationMil);
filterChain.doFilter(servletRequest, servletResponse);
isPreProcessingSucceeded = false;
-
} else if (!isCookiePresent(httpRequest.getCookies())) {
//redirect to portal app
log.debug("SessionValidationFilter: Cookie from request {} is not valid, redirecting request to portal", httpRequest.getRequestURL());
@@ -130,7 +163,7 @@ public abstract class SessionValidationFilter implements Filter {
}
private boolean processRequest(HttpServletRequest httpRequest, HttpServletResponse httpResponse, Cookie cookie) throws IOException {
- boolean isProcessSuccessful= true;
+ boolean isProcessSuccessful = true;
try {
if (AuthenticationCookieUtils.isSessionExpired(cookie, filterConfiguration)) {
//redirect to portal app
@@ -143,7 +176,6 @@ public abstract class SessionValidationFilter implements Filter {
log.debug("SessionValidationFilter: Cookie decryption error : {}", e.getMessage(), e);
isProcessSuccessful = false;
}
-
if (!isRoleValid(cookie)) {
//redirect to portal app
log.debug("SessionValidationFilter: Role is not valid, redirecting request {} to portal", httpRequest.getRequestURL());
@@ -184,33 +216,32 @@ public abstract class SessionValidationFilter implements Filter {
log.debug("SessionValidationFilter: Extracting authentication cookies, {} cookies in request", cookies.length);
List<Cookie> authenticationCookies = Arrays.stream(cookies).filter(c -> isCookieNameMatch(actualCookieName, c)).collect(Collectors.toList());
log.debug("SessionValidationFilter: Extracted {} authentication cookies from request", authenticationCookies.size());
- if( authenticationCookies.size() > 1 ){
- authenticationCookies.forEach( cookie -> log.debug("SessionValidationFilter: Multiple cookies found cookie name, {} cookie value {}", cookie.getName(), cookie.getValue()));
+ if (authenticationCookies.size() > 1) {
+ authenticationCookies.forEach(cookie -> log
+ .debug("SessionValidationFilter: Multiple cookies found cookie name, {} cookie value {}", cookie.getName(), cookie.getValue()));
}
return authenticationCookies;
}
-
// use contains for matching due issue with ecomp portal ( change cookie name, add prefix ), temp solution
private boolean isCookieNameMatch(String actualCookieName, Cookie c) {
return c.getName().contains(actualCookieName);
}
private boolean isUrlFromWhiteList(HttpServletRequest httpRequest) {
- if (httpRequest.getPathInfo() == null){
+ if (httpRequest.getPathInfo() == null) {
final String servletPath = httpRequest.getServletPath().toLowerCase();
- log.debug("SessionValidationFilter: pathInfo is null, trying to check by servlet path white list validation -> ServletPath: {} ", servletPath);
- return excludedUrls.stream().
- anyMatch( e -> servletPath.matches(e));
+ log.debug("SessionValidationFilter: pathInfo is null, trying to check by servlet path white list validation -> ServletPath: {} ",
+ servletPath);
+ return excludedUrls.stream().anyMatch(e -> servletPath.matches(e));
}
String pathInfo = httpRequest.getPathInfo().toLowerCase();
log.debug("SessionValidationFilter: white list validation -> PathInfo: {} ", pathInfo);
- return excludedUrls.stream().
- anyMatch( e -> pathInfo.matches(e));
+ return excludedUrls.stream().anyMatch(e -> pathInfo.matches(e));
}
private void cleanResponceFromLeftoverCookies(HttpServletResponse httpResponse, List<Cookie> cookiesList) {
- for (Cookie cookie:cookiesList){
+ for (Cookie cookie : cookiesList) {
Cookie cleanCookie = AuthenticationCookieUtils.createUpdatedCookie(cookie, null, filterConfiguration);
cleanCookie.setMaxAge(0);
log.debug("SessionValidationFilter Cleaning Cookie cookie name: {} added to responce", cleanCookie.getName());
@@ -218,45 +249,7 @@ public abstract class SessionValidationFilter implements Filter {
}
}
- public static void fillMDCFromHeaders(HttpServletRequest httpServletRequest) {
- fillRequestIdFromHeader(httpServletRequest);
- fillPartnerNameFromHeader(httpServletRequest);
-
- }
-
- private static void fillRequestIdFromHeader(HttpServletRequest httpServletRequest){
- if (MDC.get(REQUEST_ID) == null) {
- if (StringUtils.isNotEmpty(httpServletRequest.getHeader(ONAP_REQUEST_ID_HEADER))) {
- MDC.put(REQUEST_ID, httpServletRequest.getHeader(ONAP_REQUEST_ID_HEADER));
- } else if (StringUtils.isNotEmpty(httpServletRequest.getHeader(REQUEST_ID_HEADER))) {
- MDC.put(REQUEST_ID, httpServletRequest.getHeader(REQUEST_ID_HEADER));
- } else if (StringUtils.isNotEmpty(httpServletRequest.getHeader(TRANSACTION_ID_HEADER))) {
- MDC.put(REQUEST_ID, httpServletRequest.getHeader(TRANSACTION_ID_HEADER));
- } else if (StringUtils.isNotEmpty(httpServletRequest.getHeader(ECOMP_REQUEST_ID_HEADER))) {
- MDC.put(REQUEST_ID, httpServletRequest.getHeader(ECOMP_REQUEST_ID_HEADER));
- } else {
- MDC.put(REQUEST_ID, UUID.randomUUID().toString());
- }
- }
- }
-
- private static void fillPartnerNameFromHeader(HttpServletRequest httpServletRequest){
- if (MDC.get(PARTNER_NAME) == null) {
- if (StringUtils.isNotEmpty(httpServletRequest.getHeader(USER_ID_HEADER))) {
- MDC.put(PARTNER_NAME, httpServletRequest.getHeader(USER_ID_HEADER));
- } else if (StringUtils.isNotEmpty(httpServletRequest.getHeader(ONAP_PARTNER_NAME_HEADER))) {
- MDC.put(PARTNER_NAME, httpServletRequest.getHeader(ONAP_PARTNER_NAME_HEADER));
- } else if (StringUtils.isNotEmpty(httpServletRequest.getHeader(USER_AGENT_HEADER))) {
- MDC.put(PARTNER_NAME, httpServletRequest.getHeader(USER_AGENT_HEADER));
- } else {
- MDC.put(PARTNER_NAME, UNKNOWN);
- }
- }
- }
-
-
@Override
public void destroy() {
-
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/UploadValidationManager.java b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/UploadValidationManager.java
index 88aceeb87d..22f014742c 100644
--- a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/UploadValidationManager.java
+++ b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/UploadValidationManager.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,21 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.validation;
-import org.openecomp.sdc.validation.types.ValidationFileResponse;
-
import java.io.IOException;
import java.io.InputStream;
+import org.openecomp.sdc.validation.types.ValidationFileResponse;
/**
* Created by TALIO on 4/20/2016.
*/
public interface UploadValidationManager {
-
- ValidationFileResponse validateFile(String type, InputStream heatFileToUpload) throws IOException;
-
-
+ ValidationFileResponse validateFile(String type, InputStream heatFileToUpload) throws IOException;
}
diff --git a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java
index 90f8ad369b..6a9015489b 100644
--- a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.validation.impl;
import java.io.IOException;
@@ -44,76 +43,60 @@ import org.openecomp.sdc.validation.UploadValidationManager;
import org.openecomp.sdc.validation.types.ValidationFileResponse;
import org.openecomp.sdc.validation.util.ValidationManagerUtil;
-
/**
* Created by TALIO on 4/20/2016.
*/
public class UploadValidationManagerImpl implements UploadValidationManager {
- private static FileContentHandler getFileContentMapFromZip(byte[] uploadFileData) throws IOException {
- final Map<String, byte[]> zipFileAndByteMap;
- try {
- zipFileAndByteMap = ZipUtils.readZip(uploadFileData, true);
- } catch (final ZipException e) {
- throw new IOException(e);
+ private static FileContentHandler getFileContentMapFromZip(byte[] uploadFileData) throws IOException {
+ final Map<String, byte[]> zipFileAndByteMap;
+ try {
+ zipFileAndByteMap = ZipUtils.readZip(uploadFileData, true);
+ } catch (final ZipException e) {
+ throw new IOException(e);
+ }
+ final boolean zipHasFolders = zipFileAndByteMap.values().stream().anyMatch(Objects::isNull);
+ if (zipHasFolders) {
+ throw new CoreException((new ErrorCode.ErrorCodeBuilder()).withMessage(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage())
+ .withId(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage()).withCategory(ErrorCategory.APPLICATION).build());
+ }
+ final FileContentHandler mapFileContent = new FileContentHandler();
+ zipFileAndByteMap.entrySet().stream().filter(entry -> entry.getValue() != null)
+ .forEach(zipEntry -> mapFileContent.addFile(zipEntry.getKey(), zipEntry.getValue()));
+ return mapFileContent;
}
- final boolean zipHasFolders = zipFileAndByteMap.values().stream().anyMatch(Objects::isNull);
- if (zipHasFolders) {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage())
- .withId(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage())
- .withCategory(ErrorCategory.APPLICATION).build());
+ @Override
+ public ValidationFileResponse validateFile(String type, InputStream fileToValidate) throws IOException {
+ ValidationFileResponse validationFileResponse = new ValidationFileResponse();
+ HeatTreeManager tree;
+ ValidationStructureList validationStructureList = new ValidationStructureList();
+ if (type.equalsIgnoreCase("heat")) {
+ FileContentHandler content = getFileContent(fileToValidate);
+ if (!content.containsFile(SdcCommon.MANIFEST_NAME)) {
+ throw new CoreException((new ErrorCode.ErrorCodeBuilder()).withMessage(Messages.MANIFEST_NOT_EXIST.getErrorMessage())
+ .withId(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage()).withCategory(ErrorCategory.APPLICATION).build());
+ }
+ Map<String, List<ErrorMessage>> errors = validateHeatUploadData(content);
+ tree = HeatTreeManagerUtil.initHeatTreeManager(content);
+ tree.createTree();
+ if (MapUtils.isNotEmpty(errors)) {
+ tree.addErrors(errors);
+ validationStructureList.setImportStructure(tree.getTree());
+ }
+ } else {
+ throw new RuntimeException("invalid type:" + type);
+ }
+ validationFileResponse.setValidationData(validationStructureList);
+ return validationFileResponse;
}
- final FileContentHandler mapFileContent = new FileContentHandler();
- zipFileAndByteMap.entrySet().stream()
- .filter(entry -> entry.getValue() != null)
- .forEach(zipEntry -> mapFileContent.addFile(zipEntry.getKey(), zipEntry.getValue()));
-
- return mapFileContent;
- }
-
- @Override
- public ValidationFileResponse validateFile(String type, InputStream fileToValidate)
- throws IOException {
- ValidationFileResponse validationFileResponse = new ValidationFileResponse();
-
- HeatTreeManager tree;
- ValidationStructureList validationStructureList = new ValidationStructureList();
- if (type.equalsIgnoreCase("heat")) {
- FileContentHandler content = getFileContent(fileToValidate);
- if (!content.containsFile(SdcCommon.MANIFEST_NAME)) {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage(Messages.MANIFEST_NOT_EXIST.getErrorMessage())
- .withId(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage())
- .withCategory(ErrorCategory.APPLICATION).build());
- }
- Map<String, List<ErrorMessage>> errors = validateHeatUploadData(content);
- tree = HeatTreeManagerUtil.initHeatTreeManager(content);
- tree.createTree();
-
- if (MapUtils.isNotEmpty(errors)) {
- tree.addErrors(errors);
- validationStructureList.setImportStructure(tree.getTree());
- }
- } else {
- throw new RuntimeException("invalid type:" + type);
+ private Map<String, List<ErrorMessage>> validateHeatUploadData(FileContentHandler fileContentMap) {
+ ValidationManager validationManager = ValidationManagerUtil.initValidationManager(fileContentMap);
+ return validationManager.validate();
}
- validationFileResponse.setValidationData(validationStructureList);
- return validationFileResponse;
- }
-
- private Map<String, List<ErrorMessage>> validateHeatUploadData(FileContentHandler fileContentMap) {
- ValidationManager validationManager =
- ValidationManagerUtil.initValidationManager(fileContentMap);
- return validationManager.validate();
- }
-
- private FileContentHandler getFileContent(InputStream is) throws IOException {
- return getFileContentMapFromZip(FileUtils.toByteArray(is));
-
-
- }
+ private FileContentHandler getFileContent(InputStream is) throws IOException {
+ return getFileContentMapFromZip(FileUtils.toByteArray(is));
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/types/ValidationFileResponse.java b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/types/ValidationFileResponse.java
index bf6923d3de..41de2b73a3 100644
--- a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/types/ValidationFileResponse.java
+++ b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/types/ValidationFileResponse.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,19 +17,19 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.validation.types;
import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
public class ValidationFileResponse {
- private ValidationStructureList validationData;
- public ValidationStructureList getValidationData() {
- return validationData;
- }
+ private ValidationStructureList validationData;
+
+ public ValidationStructureList getValidationData() {
+ return validationData;
+ }
- public void setValidationData(ValidationStructureList validationData) {
- this.validationData = validationData;
- }
+ public void setValidationData(ValidationStructureList validationData) {
+ this.validationData = validationData;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/types/ValidationFileStatus.java b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/types/ValidationFileStatus.java
index 4bf7be8b79..2ed4520f2a 100644
--- a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/types/ValidationFileStatus.java
+++ b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/types/ValidationFileStatus.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,10 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.validation.types;
public enum ValidationFileStatus {
- Success,
- Failure
+ Success, Failure
}
diff --git a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java
index 6a7466d20d..3117082419 100644
--- a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java
+++ b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java
@@ -13,9 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.validation.util;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.validation.api.ValidationManager;
@@ -25,42 +28,36 @@ import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-import java.util.Map;
-
-
public class ValidationManagerUtil {
- private ValidationManagerUtil(){}
+ private ValidationManagerUtil() {
+ }
- /**
- * Handle missing manifest.
- *
- * @param fileContentMap the file content map
- * @param errors the errors
- */
- public static void handleMissingManifest(FileContentHandler fileContentMap,
- Map<String, List<ErrorMessage>> errors) throws IOException {
- try (InputStream manifest = fileContentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) {
- if (manifest == null) {
- ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.MANIFEST_NAME, errors)
- .add(new ErrorMessage(ErrorLevel.ERROR, Messages.MANIFEST_NOT_EXIST.getErrorMessage()));
- }
+ /**
+ * Handle missing manifest.
+ *
+ * @param fileContentMap the file content map
+ * @param errors the errors
+ */
+ public static void handleMissingManifest(FileContentHandler fileContentMap, Map<String, List<ErrorMessage>> errors) throws IOException {
+ try (InputStream manifest = fileContentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) {
+ if (manifest == null) {
+ ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.MANIFEST_NAME, errors)
+ .add(new ErrorMessage(ErrorLevel.ERROR, Messages.MANIFEST_NOT_EXIST.getErrorMessage()));
+ }
+ }
}
- }
- /**
- * Init validation manager validation manager.
- *
- * @param fileContentMap the file content map
- * @return the validation manager
- */
- public static ValidationManager initValidationManager(FileContentHandler fileContentMap) {
- ValidationManager validationManager = ValidationManagerFactory.getInstance().createInterface();
- fileContentMap.getFileList().forEach(fileName -> validationManager
- .addFile(fileName, FileUtils.toByteArray(fileContentMap.getFileContentAsStream(fileName))));
- return validationManager;
- }
+ /**
+ * Init validation manager validation manager.
+ *
+ * @param fileContentMap the file content map
+ * @return the validation manager
+ */
+ public static ValidationManager initValidationManager(FileContentHandler fileContentMap) {
+ ValidationManager validationManager = ValidationManagerFactory.getInstance().createInterface();
+ fileContentMap.getFileList()
+ .forEach(fileName -> validationManager.addFile(fileName, FileUtils.toByteArray(fileContentMap.getFileContentAsStream(fileName))));
+ return validationManager;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java
index 60288b53c3..c5c93ae00c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,82 +17,80 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorlicense;
-import org.openecomp.sdc.vendorlicense.dao.types.*;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
import java.util.Collection;
import java.util.Set;
+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.LicenseAgreementEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementModel;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
+import org.openecomp.sdc.versioning.dao.types.Version;
public interface VendorLicenseManager {
- void validate(String vendorLicenseModelId, Version version);
-
- VendorLicenseModelEntity createVendorLicenseModel(VendorLicenseModelEntity licenseModel);
-
- void updateVendorLicenseModel(VendorLicenseModelEntity licenseModel);
-
- VendorLicenseModelEntity getVendorLicenseModel(String vlmId, Version version);
-
- void deleteVendorLicenseModel(String vlmId, Version version);
+ void validate(String vendorLicenseModelId, Version version);
+ VendorLicenseModelEntity createVendorLicenseModel(VendorLicenseModelEntity licenseModel);
- Collection<LicenseAgreementEntity> listLicenseAgreements(String vlmId, Version version);
+ void updateVendorLicenseModel(VendorLicenseModelEntity licenseModel);
- LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement);
+ VendorLicenseModelEntity getVendorLicenseModel(String vlmId, Version version);
- void updateLicenseAgreement(LicenseAgreementEntity licenseAgreement,
- Set<String> addedFeatureGroupIds, Set<String> removedFeatureGroupIds);
+ void deleteVendorLicenseModel(String vlmId, Version version);
- LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version,
- String licenseAgreementId);
+ Collection<LicenseAgreementEntity> listLicenseAgreements(String vlmId, Version version);
- void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId);
+ LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement);
+ void updateLicenseAgreement(LicenseAgreementEntity licenseAgreement, Set<String> addedFeatureGroupIds, Set<String> removedFeatureGroupIds);
- Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version);
+ LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version, String licenseAgreementId);
- FeatureGroupEntity createFeatureGroup(FeatureGroupEntity fg);
+ void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId);
- void updateFeatureGroup(FeatureGroupEntity featureGroup,
- Set<String> addedLicenseKeyGroups, Set<String> removedLicenseKeyGroups,
- Set<String> addedEntitlementPools, Set<String> removedEntitlementPools);
+ Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version);
- FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup);
+ FeatureGroupEntity createFeatureGroup(FeatureGroupEntity fg);
- void deleteFeatureGroup(FeatureGroupEntity featureGroup);
+ void updateFeatureGroup(FeatureGroupEntity featureGroup, Set<String> addedLicenseKeyGroups, Set<String> removedLicenseKeyGroups,
+ Set<String> addedEntitlementPools, Set<String> removedEntitlementPools);
+ FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup);
- Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version);
+ void deleteFeatureGroup(FeatureGroupEntity featureGroup);
- EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool);
+ Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version);
- void updateEntitlementPool(EntitlementPoolEntity entitlementPool);
+ EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool);
- EntitlementPoolEntity getEntitlementPool(EntitlementPoolEntity entitlementPool);
+ void updateEntitlementPool(EntitlementPoolEntity entitlementPool);
- void deleteEntitlementPool(EntitlementPoolEntity entitlementPool);
+ EntitlementPoolEntity getEntitlementPool(EntitlementPoolEntity entitlementPool);
+ void deleteEntitlementPool(EntitlementPoolEntity entitlementPool);
- Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version);
+ Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version);
- LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
+ LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
- void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
+ void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
- LicenseKeyGroupEntity getLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
+ LicenseKeyGroupEntity getLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
- void deleteLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
+ void deleteLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
- LimitEntity createLimit(LimitEntity limitEntity);
+ LimitEntity createLimit(LimitEntity limitEntity);
- Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId);
+ Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId);
- void deleteLimit(LimitEntity limitEntity);
+ void deleteLimit(LimitEntity limitEntity);
- void updateLimit(LimitEntity limitEntity);
+ void updateLimit(LimitEntity limitEntity);
- LimitEntity getLimit(LimitEntity entitlementPool);
+ LimitEntity getLimit(LimitEntity entitlementPool);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManagerFactory.java
index 68ea919d22..fa05c03b5e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManagerFactory.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorlicense;
import org.openecomp.core.factory.api.AbstractComponentFactory;
@@ -26,10 +25,9 @@ import org.openecomp.core.factory.api.AbstractFactory;
/**
* Created by ayalaben on 8/3/2017
*/
-public abstract class VendorLicenseManagerFactory extends
- AbstractComponentFactory<VendorLicenseManager> {
+public abstract class VendorLicenseManagerFactory extends AbstractComponentFactory<VendorLicenseManager> {
- public static VendorLicenseManagerFactory getInstance() {
- return AbstractFactory.getInstance(VendorLicenseManagerFactory.class);
- }
+ public static VendorLicenseManagerFactory getInstance() {
+ return AbstractFactory.getInstance(VendorLicenseManagerFactory.class);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/errors/LimitErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/errors/LimitErrorBuilder.java
index b2a155dc21..3c0463596a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/errors/LimitErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/errors/LimitErrorBuilder.java
@@ -13,38 +13,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorlicense.errors;
-
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
public class LimitErrorBuilder {
- private static final String LIMIT_INVALID_ATTR_VALUE_MSG = "The %s value doesn't meet the "
- + "expected attribute value.";
-
- private static final String DUPLICATE_LIMIT_NAME_NOT_ALLOWED_MSG =
- "Invalid request, Limit with name %s already exists for type %s.";
-
- private LimitErrorBuilder(){
-
- }
-
- public static ErrorCode getInvalidValueErrorBuilder(String attribute, String errorCode) {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(errorCode);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(LIMIT_INVALID_ATTR_VALUE_MSG, attribute));
- return builder.build();
- }
-
- public static ErrorCode getDuplicateNameErrorbuilder(String name, String type) {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(VendorLicenseErrorCodes.DUPLICATE_LIMIT_NAME_NOT_ALLOWED);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format (DUPLICATE_LIMIT_NAME_NOT_ALLOWED_MSG, name, type ));
- return builder.build();
- }
+ private static final String LIMIT_INVALID_ATTR_VALUE_MSG = "The %s value doesn't meet the " + "expected attribute value.";
+ private static final String DUPLICATE_LIMIT_NAME_NOT_ALLOWED_MSG = "Invalid request, Limit with name %s already exists for type %s.";
+
+ private LimitErrorBuilder() {
+ }
+
+ public static ErrorCode getInvalidValueErrorBuilder(String attribute, String errorCode) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(errorCode);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(LIMIT_INVALID_ATTR_VALUE_MSG, attribute));
+ return builder.build();
+ }
+
+ public static ErrorCode getDuplicateNameErrorbuilder(String name, String type) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorLicenseErrorCodes.DUPLICATE_LIMIT_NAME_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DUPLICATE_LIMIT_NAME_NOT_ALLOWED_MSG, name, type));
+ return builder.build();
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerFactoryImpl.java
index ac7eb115b1..16a789bd8d 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerFactoryImpl.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,33 +17,32 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorlicense.impl;
import org.openecomp.core.dao.UniqueValueDaoFactory;
import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory;
-import org.openecomp.sdc.vendorlicense.dao.*;
+import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.LimitDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDaoFactory;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
/**
* Created by ayalaben on 8/3/2017
*/
public class VendorLicenseManagerFactoryImpl extends VendorLicenseManagerFactory {
- private static final VendorLicenseManager INSTANCE =
- new VendorLicenseManagerImpl(
- VendorLicenseFacadeFactory.getInstance().createInterface(),
- VendorLicenseModelDaoFactory.getInstance().createInterface(),
- LicenseAgreementDaoFactory.getInstance().createInterface(),
- FeatureGroupDaoFactory.getInstance().createInterface(),
- EntitlementPoolDaoFactory.getInstance().createInterface(),
- LicenseKeyGroupDaoFactory.getInstance().createInterface(),
- LimitDaoFactory.getInstance().createInterface(),
- UniqueValueDaoFactory.getInstance().createInterface());
- @Override
- public VendorLicenseManager createInterface() {
- return INSTANCE;
- }
+ private static final VendorLicenseManager INSTANCE = new VendorLicenseManagerImpl(VendorLicenseFacadeFactory.getInstance().createInterface(),
+ VendorLicenseModelDaoFactory.getInstance().createInterface(), LicenseAgreementDaoFactory.getInstance().createInterface(),
+ FeatureGroupDaoFactory.getInstance().createInterface(), EntitlementPoolDaoFactory.getInstance().createInterface(),
+ LicenseKeyGroupDaoFactory.getInstance().createInterface(), LimitDaoFactory.getInstance().createInterface(),
+ UniqueValueDaoFactory.getInstance().createInterface());
+ @Override
+ public VendorLicenseManager createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java
index 6939eeed32..0fb5f58507 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java
@@ -13,9 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorlicense.impl;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.Collection;
+import java.util.Optional;
+import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.openecomp.core.dao.UniqueValueDao;
import org.openecomp.core.util.UniqueValueUtil;
@@ -45,596 +49,471 @@ import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.time.LocalDate;
-import java.time.format.DateTimeFormatter;
-import java.util.Collection;
-import java.util.Optional;
-import java.util.Set;
-
public class VendorLicenseManagerImpl implements VendorLicenseManager {
- private UniqueValueUtil uniqueValueUtil;
- private VendorLicenseFacade vendorLicenseFacade;
- private VendorLicenseModelDao vendorLicenseModelDao;
- private LicenseAgreementDao licenseAgreementDao;
- private FeatureGroupDao featureGroupDao;
- private EntitlementPoolDao entitlementPoolDao;
- private LicenseKeyGroupDao licenseKeyGroupDao;
- private LimitDao limitDao;
-
- private static final String EP_POOL_START_TIME = "T00:00:00Z";
- private static final String EP_POOL_EXPIRY_TIME = "T23:59:59Z";
- private static final DateTimeFormatter FORMATTER
- = DateTimeFormatter.ofPattern("MM/dd/yyyy'T'HH:mm:ss'Z'");
- public VendorLicenseManagerImpl(VendorLicenseFacade vendorLicenseFacade,
- VendorLicenseModelDao vendorLicenseModelDao,
- LicenseAgreementDao licenseAgreementDao,
- FeatureGroupDao featureGroupDao,
- EntitlementPoolDao entitlementPoolDao,
- LicenseKeyGroupDao licenseKeyGroupDao,
- LimitDao limitDao,
- UniqueValueDao uniqueValueDao) {
- this.vendorLicenseFacade = vendorLicenseFacade;
- this.vendorLicenseModelDao = vendorLicenseModelDao;
- this.licenseAgreementDao = licenseAgreementDao;
- this.featureGroupDao = featureGroupDao;
- this.entitlementPoolDao = entitlementPoolDao;
- this.licenseKeyGroupDao = licenseKeyGroupDao;
- this.limitDao = limitDao;
- this.uniqueValueUtil = new UniqueValueUtil(uniqueValueDao);
- }
-
-
- @Override
- public void validate(String vendorLicenseModelId, Version version) {
- vendorLicenseFacade.validate(vendorLicenseModelId, version);
- }
-
- @Override
- public VendorLicenseModelEntity createVendorLicenseModel(
- VendorLicenseModelEntity vendorLicenseModelEntity) {
- vendorLicenseModelDao.create(vendorLicenseModelEntity);
- return vendorLicenseModelEntity;
- }
-
- @Override
- public void updateVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModelEntity) {
- VendorLicenseModelEntity retrieved = vendorLicenseModelDao.get(vendorLicenseModelEntity);
- if (retrieved == null){
- throw new CoreException((new ErrorCode.ErrorCodeBuilder()
- .withMessage(String.format("Vlm with id %s and version %s does not exist.",
- vendorLicenseModelEntity.getId(), vendorLicenseModelEntity.getVersion().getId()))).build());
- }
-
- String existingVendorName = retrieved.getVendorName();
-
- updateUniqueName(VendorLicenseConstants.UniqueValues.VENDOR_NAME, existingVendorName,
- vendorLicenseModelEntity.getVendorName());
- vendorLicenseModelDao.update(vendorLicenseModelEntity);
- }
-
- @Override
- public VendorLicenseModelEntity getVendorLicenseModel(String vlmId, Version version) {
- return vendorLicenseFacade.getVendorLicenseModel(vlmId, version);
- }
-
- @Override
- public void deleteVendorLicenseModel(String vlmId, Version version) {
- throw new UnsupportedOperationException(VendorLicenseConstants.UNSUPPORTED_OPERATION_ERROR);
- }
-
- @Override
- public Collection<LicenseAgreementEntity> listLicenseAgreements(String vlmId, Version version) {
- return licenseAgreementDao.list(new LicenseAgreementEntity(vlmId, version, null));
- }
-
- @Override
- public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement) {
- return vendorLicenseFacade.createLicenseAgreement(licenseAgreement);
- }
-
- @Override
- public void updateLicenseAgreement(LicenseAgreementEntity licenseAgreement,
- Set<String> addedFeatureGroupIds,
- Set<String> removedFeatureGroupIds) {
- LicenseAgreementEntity retrieved = licenseAgreementDao.get(licenseAgreement);
- VersioningUtil
- .validateEntityExistence(retrieved, licenseAgreement, VendorLicenseModelEntity.ENTITY_TYPE);
- VersioningUtil.validateContainedEntitiesExistence(new FeatureGroupEntity().getEntityType(),
- removedFeatureGroupIds, retrieved, retrieved.getFeatureGroupIds());
- VersioningUtil.validateEntitiesExistence(addedFeatureGroupIds,
- new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
- licenseAgreement.getVersion(),
- null),
- featureGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
-
- updateUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
- retrieved.getName(), licenseAgreement.getName(), licenseAgreement.getVendorLicenseModelId(),
- licenseAgreement.getVersion().getId());
- licenseAgreementDao.updateColumnsAndDeltaFeatureGroupIds(licenseAgreement, addedFeatureGroupIds,
- removedFeatureGroupIds);
-
- addFeatureGroupsToLicenseAgreementRef(addedFeatureGroupIds, licenseAgreement);
- removeFeatureGroupsToLicenseAgreementRef(removedFeatureGroupIds, licenseAgreement);
- }
-
- @Override
- public LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version,
- String licenseAgreementId) {
- return vendorLicenseFacade.getLicenseAgreementModel(vlmId, version, licenseAgreementId);
- }
-
- @Override
- public void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId) {
- LicenseAgreementEntity input =
- new LicenseAgreementEntity(vlmId, version, licenseAgreementId);
- LicenseAgreementEntity retrieved = licenseAgreementDao.get(input);
- VersioningUtil.validateEntityExistence(retrieved, input, VendorLicenseModelEntity.ENTITY_TYPE);
-
- removeFeatureGroupsToLicenseAgreementRef(retrieved.getFeatureGroupIds(), retrieved);
-
- licenseAgreementDao.delete(retrieved);
-
- deleteUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
- retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
- retrieved.getName());
- }
-
- @Override
- public Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version) {
- return vendorLicenseFacade.listFeatureGroups(vlmId, version);
- }
-
- @Override
- public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup) {
- return vendorLicenseFacade.createFeatureGroup(featureGroup);
- }
-
- @Override
- public void updateFeatureGroup(FeatureGroupEntity featureGroup,
- Set<String> addedLicenseKeyGroups,
- Set<String> removedLicenseKeyGroups,
- Set<String> addedEntitlementPools,
- Set<String> removedEntitlementPools) {
- FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
- VersioningUtil
- .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
-
- VersioningUtil.validateContainedEntitiesExistence(new LicenseKeyGroupEntity().getEntityType(),
- removedLicenseKeyGroups, retrieved, retrieved.getLicenseKeyGroupIds());
- VersioningUtil.validateContainedEntitiesExistence(new EntitlementPoolEntity().getEntityType(),
- removedEntitlementPools, retrieved, retrieved.getEntitlementPoolIds());
-
- VersioningUtil.validateEntitiesExistence(addedLicenseKeyGroups,
- new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(),
- null),
- licenseKeyGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
- VersioningUtil.validateEntitiesExistence(addedEntitlementPools,
- new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(),
- null),
- entitlementPoolDao, VendorLicenseModelEntity.ENTITY_TYPE);
-
- updateUniqueName(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
- retrieved.getName(), featureGroup.getName(), featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion().getId());
-
- addLicenseKeyGroupsToFeatureGroupsRef(addedLicenseKeyGroups, featureGroup);
- removeLicenseKeyGroupsToFeatureGroupsRef(removedLicenseKeyGroups, featureGroup);
- addEntitlementPoolsToFeatureGroupsRef(addedEntitlementPools, featureGroup);
- removeEntitlementPoolsToFeatureGroupsRef(removedEntitlementPools, featureGroup);
-
- featureGroupDao.updateFeatureGroup(featureGroup, addedEntitlementPools, removedEntitlementPools,
- addedLicenseKeyGroups, removedLicenseKeyGroups);
-
- }
-
- @Override
- public FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup) {
- return vendorLicenseFacade.getFeatureGroupModel(featureGroup);
- }
-
- @Override
- public void deleteFeatureGroup(FeatureGroupEntity featureGroup) {
- FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
- VersioningUtil
- .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
-
- removeLicenseKeyGroupsToFeatureGroupsRef(retrieved.getLicenseKeyGroupIds(), featureGroup);
- removeEntitlementPoolsToFeatureGroupsRef(retrieved.getEntitlementPoolIds(), featureGroup);
-
- for (String licenceAgreementId : retrieved.getReferencingLicenseAgreements()) {
- licenseAgreementDao.removeFeatureGroup(
- new LicenseAgreementEntity(featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion(),
- licenceAgreementId), featureGroup.getId());
- }
-
- featureGroupDao.delete(featureGroup);
-
- deleteUniqueName(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
- retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
- retrieved.getName());
- }
-
- @Override
- public Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version) {
- return vendorLicenseFacade.listEntitlementPools(vlmId, version);
- }
-
- @Override
- public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool) {
- entitlementPool.setStartDate(getDate(entitlementPool.getStartDate(), EP_POOL_START_TIME));
- entitlementPool.setExpiryDate(getDate(entitlementPool.getExpiryDate(), EP_POOL_EXPIRY_TIME));
- validateCreateDate(entitlementPool.getStartDate(), entitlementPool.getExpiryDate(),
- entitlementPool.getVendorLicenseModelId());
- return vendorLicenseFacade.createEntitlementPool(entitlementPool);
- }
-
- private String getDate(String date, String poolTime){
- return date != null ? (!date.trim().isEmpty() ? date + poolTime: null) : null;
- }
-
- private void validateCreateDate(String startDate, String expiryDate,
- String vendorLicenseModelId) {
- //original logic allows both nulls
- if(StringUtils.isEmpty(startDate) && StringUtils.isEmpty(expiryDate)){
- return;
- }
-
- Optional<LocalDate> parsedStartDate = parseLocalDate(startDate);
- Optional<LocalDate> parsedExpiryDate = parseLocalDate(expiryDate);
- if (!parsedStartDate.isPresent()) {
- throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
- }
-
- if (!parsedExpiryDate.isPresent()
- && parsedStartDate.get().atStartOfDay().isBefore
- (LocalDate.now().atStartOfDay())) {
- throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
- }
-
- if(parsedExpiryDate.isPresent() && isNotValidatStartAndExpiryDate(parsedStartDate.get(), parsedExpiryDate.get())){
- throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
- }
- }
-
- private boolean isNotValidatStartAndExpiryDate(LocalDate parsedStartDate,
- LocalDate parsedExpiryDate) {
- return parsedStartDate.atStartOfDay().isBefore(LocalDate.now().atStartOfDay())
- || parsedExpiryDate.atStartOfDay().isEqual(parsedStartDate.atStartOfDay())
- || parsedExpiryDate.isBefore(parsedStartDate);
- }
-
- private static Optional<LocalDate> parseLocalDate(String date) {
- if (StringUtils.isEmpty(date)) {
- return Optional.empty();
- }
-
- return Optional.of(LocalDate.parse(date, FORMATTER ));
- }
-
- private void validateUpdateDate(String startDate, String expiryDate,
- String vendorLicenseModelId) {
- Optional<LocalDate> parsedStartDate = parseLocalDate(startDate);
- Optional<LocalDate> parsedExpiryDate = parseLocalDate(expiryDate);
-
- if (parsedStartDate.isPresent() && parsedExpiryDate.isPresent()
- && (parsedExpiryDate.get().atStartOfDay()
- .isEqual(parsedStartDate.get().atStartOfDay())
- || parsedExpiryDate.get().isBefore(parsedStartDate.get() ))) {
- throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
- }
-
- if (startDate == null && expiryDate != null) {
- throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
- }
- }
-
- @Override
- public void updateEntitlementPool(EntitlementPoolEntity entitlementPool) {
- entitlementPool.setStartDate(getDate(entitlementPool.getStartDate(), EP_POOL_START_TIME));
- entitlementPool.setExpiryDate(getDate(entitlementPool.getExpiryDate(), EP_POOL_EXPIRY_TIME));
- validateUpdateDate(entitlementPool.getStartDate(), entitlementPool.getExpiryDate(),
- entitlementPool.getVendorLicenseModelId());
- vendorLicenseFacade.updateEntitlementPool(entitlementPool);
- }
-
- @Override
- public EntitlementPoolEntity getEntitlementPool(EntitlementPoolEntity entitlementPool) {
- EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
- VersioningUtil
- .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
- DateTimeFormatter targetFormatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- if (retrieved.getStartDate() != null) {
- retrieved.setStartDate(LocalDate.parse(retrieved.getStartDate(), FORMATTER ).format
- (targetFormatter));
- }
-
- if (retrieved.getExpiryDate() != null) {
- retrieved.setExpiryDate(LocalDate.parse(retrieved.getExpiryDate(), FORMATTER ).format
- (targetFormatter));
- }
- return retrieved;
- }
-
- @Override
- public void deleteEntitlementPool(EntitlementPoolEntity entitlementPool) {
- EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
- VersioningUtil
- .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
-
- for (String referencingFeatureGroupId : retrieved.getReferencingFeatureGroups()) {
- featureGroupDao.removeEntitlementPool(
- new FeatureGroupEntity(entitlementPool.getVendorLicenseModelId(),
- entitlementPool.getVersion(),
- referencingFeatureGroupId), entitlementPool.getId());
- }
-
- deleteChildLimits(entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion(),
- entitlementPool.getId());
-
- entitlementPoolDao.delete(entitlementPool);
-
- deleteUniqueName(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME,
- retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
- retrieved.getName());
- }
-
- protected void deleteChildLimits(String vlmId, Version version, String epLkgId) {
- Optional<Collection<LimitEntity>> limitEntities = Optional.ofNullable(
- listLimits(vlmId, version, epLkgId));
- limitEntities.ifPresent(entities -> entities.forEach(this::deleteLimit));
- }
-
- @Override
- public Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version) {
- return vendorLicenseFacade.listLicenseKeyGroups(vlmId, version);
- }
-
- @Override
- public LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
- licenseKeyGroup.setStartDate(licenseKeyGroup.getStartDate() != null ? (licenseKeyGroup
- .getStartDate().trim().length() != 0 ? licenseKeyGroup.getStartDate() + EP_POOL_START_TIME
- : null) : null);
- licenseKeyGroup.setExpiryDate(licenseKeyGroup.getExpiryDate() != null ? (licenseKeyGroup
- .getExpiryDate().trim().length() != 0 ? licenseKeyGroup.getExpiryDate() + EP_POOL_EXPIRY_TIME
- : null) : null);
-
- validateCreateDate(licenseKeyGroup.getStartDate(), licenseKeyGroup.getExpiryDate(),
- licenseKeyGroup.getVendorLicenseModelId());
- return vendorLicenseFacade.createLicenseKeyGroup(licenseKeyGroup);
- }
-
- @Override
- public void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
- licenseKeyGroup.setStartDate(licenseKeyGroup.getStartDate() != null ? (licenseKeyGroup
- .getStartDate().trim().length() != 0 ? licenseKeyGroup.getStartDate() + EP_POOL_START_TIME
- : null) : null);
- licenseKeyGroup.setExpiryDate(licenseKeyGroup.getExpiryDate() != null ? (licenseKeyGroup
- .getExpiryDate().trim().length() != 0 ? licenseKeyGroup.getExpiryDate() + EP_POOL_EXPIRY_TIME
- : null) : null);
-
- validateUpdateDate(licenseKeyGroup.getStartDate(), licenseKeyGroup.getExpiryDate(),
- licenseKeyGroup.getVendorLicenseModelId());
- vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroup);
- }
-
- @Override
- public LicenseKeyGroupEntity getLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
- LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
- VersioningUtil
- .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
- return retrieved;
- }
-
- @Override
- public void deleteLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
- LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
- VersioningUtil
- .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
-
- for (String referencingFeatureGroupId : retrieved.getReferencingFeatureGroups()) {
- featureGroupDao.removeLicenseKeyGroup(
- new FeatureGroupEntity(licenseKeyGroup.getVendorLicenseModelId(),
- licenseKeyGroup.getVersion(),
- referencingFeatureGroupId), licenseKeyGroup.getId());
- }
-
- deleteChildLimits(licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion(),
- licenseKeyGroup.getId());
-
- licenseKeyGroupDao.delete(licenseKeyGroup);
-
- deleteUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME,
- retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
- retrieved.getName());
- }
-
- @Override
- public LimitEntity createLimit(LimitEntity limit) {
- validateLimit(limit);
- LimitEntity createdLimit = vendorLicenseFacade.createLimit(limit);
- updateParentForLimit(limit);
- return createdLimit;
- }
-
- private void validateLimit(LimitEntity limit) {
- Collection<LimitEntity> limitList =
- listLimits(limit.getVendorLicenseModelId(), limit.getVersion()
- , limit.getEpLkgId());
-
- if (!isLimitNameUnique(limitList, limit.getName(), limit.getType(), limit.getId())) {
- final ErrorCode duplicateLimitNameErrorBuilder =
- LimitErrorBuilder.getDuplicateNameErrorbuilder(limit.getName(), limit.getType().name());
- throw new CoreException(duplicateLimitNameErrorBuilder);
- }
- }
-
- private boolean isLimitNameUnique(Collection<LimitEntity> limitList, String name, LimitType
- type, String id) {
- for (LimitEntity limit : limitList) {
- if (limit.getName().equalsIgnoreCase(name) &&
- limit.getType().name().equalsIgnoreCase(type.name())) {
- if (id != null && limit.getId().equals(id)) {
- continue;
+
+ private static final String EP_POOL_START_TIME = "T00:00:00Z";
+ private static final String EP_POOL_EXPIRY_TIME = "T23:59:59Z";
+ private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("MM/dd/yyyy'T'HH:mm:ss'Z'");
+ private UniqueValueUtil uniqueValueUtil;
+ private VendorLicenseFacade vendorLicenseFacade;
+ private VendorLicenseModelDao vendorLicenseModelDao;
+ private LicenseAgreementDao licenseAgreementDao;
+ private FeatureGroupDao featureGroupDao;
+ private EntitlementPoolDao entitlementPoolDao;
+ private LicenseKeyGroupDao licenseKeyGroupDao;
+ private LimitDao limitDao;
+
+ public VendorLicenseManagerImpl(VendorLicenseFacade vendorLicenseFacade, VendorLicenseModelDao vendorLicenseModelDao,
+ LicenseAgreementDao licenseAgreementDao, FeatureGroupDao featureGroupDao, EntitlementPoolDao entitlementPoolDao,
+ LicenseKeyGroupDao licenseKeyGroupDao, LimitDao limitDao, UniqueValueDao uniqueValueDao) {
+ this.vendorLicenseFacade = vendorLicenseFacade;
+ this.vendorLicenseModelDao = vendorLicenseModelDao;
+ this.licenseAgreementDao = licenseAgreementDao;
+ this.featureGroupDao = featureGroupDao;
+ this.entitlementPoolDao = entitlementPoolDao;
+ this.licenseKeyGroupDao = licenseKeyGroupDao;
+ this.limitDao = limitDao;
+ this.uniqueValueUtil = new UniqueValueUtil(uniqueValueDao);
+ }
+
+ private static Optional<LocalDate> parseLocalDate(String date) {
+ if (StringUtils.isEmpty(date)) {
+ return Optional.empty();
+ }
+ return Optional.of(LocalDate.parse(date, FORMATTER));
+ }
+
+ @Override
+ public void validate(String vendorLicenseModelId, Version version) {
+ vendorLicenseFacade.validate(vendorLicenseModelId, version);
+ }
+
+ @Override
+ public VendorLicenseModelEntity createVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModelEntity) {
+ vendorLicenseModelDao.create(vendorLicenseModelEntity);
+ return vendorLicenseModelEntity;
+ }
+
+ @Override
+ public void updateVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModelEntity) {
+ VendorLicenseModelEntity retrieved = vendorLicenseModelDao.get(vendorLicenseModelEntity);
+ if (retrieved == null) {
+ throw new CoreException((new ErrorCode.ErrorCodeBuilder().withMessage(String
+ .format("Vlm with id %s and version %s does not exist.", vendorLicenseModelEntity.getId(),
+ vendorLicenseModelEntity.getVersion().getId()))).build());
+ }
+ String existingVendorName = retrieved.getVendorName();
+ updateUniqueName(VendorLicenseConstants.UniqueValues.VENDOR_NAME, existingVendorName, vendorLicenseModelEntity.getVendorName());
+ vendorLicenseModelDao.update(vendorLicenseModelEntity);
+ }
+
+ @Override
+ public VendorLicenseModelEntity getVendorLicenseModel(String vlmId, Version version) {
+ return vendorLicenseFacade.getVendorLicenseModel(vlmId, version);
+ }
+
+ @Override
+ public void deleteVendorLicenseModel(String vlmId, Version version) {
+ throw new UnsupportedOperationException(VendorLicenseConstants.UNSUPPORTED_OPERATION_ERROR);
+ }
+
+ @Override
+ public Collection<LicenseAgreementEntity> listLicenseAgreements(String vlmId, Version version) {
+ return licenseAgreementDao.list(new LicenseAgreementEntity(vlmId, version, null));
+ }
+
+ @Override
+ public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement) {
+ return vendorLicenseFacade.createLicenseAgreement(licenseAgreement);
+ }
+
+ @Override
+ public void updateLicenseAgreement(LicenseAgreementEntity licenseAgreement, Set<String> addedFeatureGroupIds,
+ Set<String> removedFeatureGroupIds) {
+ LicenseAgreementEntity retrieved = licenseAgreementDao.get(licenseAgreement);
+ VersioningUtil.validateEntityExistence(retrieved, licenseAgreement, VendorLicenseModelEntity.ENTITY_TYPE);
+ VersioningUtil.validateContainedEntitiesExistence(new FeatureGroupEntity().getEntityType(), removedFeatureGroupIds, retrieved,
+ retrieved.getFeatureGroupIds());
+ VersioningUtil.validateEntitiesExistence(addedFeatureGroupIds,
+ new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion(), null), featureGroupDao,
+ VendorLicenseModelEntity.ENTITY_TYPE);
+ updateUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME, retrieved.getName(), licenseAgreement.getName(),
+ licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion().getId());
+ licenseAgreementDao.updateColumnsAndDeltaFeatureGroupIds(licenseAgreement, addedFeatureGroupIds, removedFeatureGroupIds);
+ addFeatureGroupsToLicenseAgreementRef(addedFeatureGroupIds, licenseAgreement);
+ removeFeatureGroupsToLicenseAgreementRef(removedFeatureGroupIds, licenseAgreement);
+ }
+
+ @Override
+ public LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version, String licenseAgreementId) {
+ return vendorLicenseFacade.getLicenseAgreementModel(vlmId, version, licenseAgreementId);
+ }
+
+ @Override
+ public void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId) {
+ LicenseAgreementEntity input = new LicenseAgreementEntity(vlmId, version, licenseAgreementId);
+ LicenseAgreementEntity retrieved = licenseAgreementDao.get(input);
+ VersioningUtil.validateEntityExistence(retrieved, input, VendorLicenseModelEntity.ENTITY_TYPE);
+ removeFeatureGroupsToLicenseAgreementRef(retrieved.getFeatureGroupIds(), retrieved);
+ licenseAgreementDao.delete(retrieved);
+ deleteUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME, retrieved.getVendorLicenseModelId(),
+ retrieved.getVersion().toString(), retrieved.getName());
+ }
+
+ @Override
+ public Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version) {
+ return vendorLicenseFacade.listFeatureGroups(vlmId, version);
+ }
+
+ @Override
+ public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup) {
+ return vendorLicenseFacade.createFeatureGroup(featureGroup);
+ }
+
+ @Override
+ public void updateFeatureGroup(FeatureGroupEntity featureGroup, Set<String> addedLicenseKeyGroups, Set<String> removedLicenseKeyGroups,
+ Set<String> addedEntitlementPools, Set<String> removedEntitlementPools) {
+ FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
+ VersioningUtil.validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
+ VersioningUtil.validateContainedEntitiesExistence(new LicenseKeyGroupEntity().getEntityType(), removedLicenseKeyGroups, retrieved,
+ retrieved.getLicenseKeyGroupIds());
+ VersioningUtil.validateContainedEntitiesExistence(new EntitlementPoolEntity().getEntityType(), removedEntitlementPools, retrieved,
+ retrieved.getEntitlementPoolIds());
+ VersioningUtil.validateEntitiesExistence(addedLicenseKeyGroups,
+ new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(), null), licenseKeyGroupDao,
+ VendorLicenseModelEntity.ENTITY_TYPE);
+ VersioningUtil.validateEntitiesExistence(addedEntitlementPools,
+ new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(), null), entitlementPoolDao,
+ VendorLicenseModelEntity.ENTITY_TYPE);
+ updateUniqueName(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME, retrieved.getName(), featureGroup.getName(),
+ featureGroup.getVendorLicenseModelId(), featureGroup.getVersion().getId());
+ addLicenseKeyGroupsToFeatureGroupsRef(addedLicenseKeyGroups, featureGroup);
+ removeLicenseKeyGroupsToFeatureGroupsRef(removedLicenseKeyGroups, featureGroup);
+ addEntitlementPoolsToFeatureGroupsRef(addedEntitlementPools, featureGroup);
+ removeEntitlementPoolsToFeatureGroupsRef(removedEntitlementPools, featureGroup);
+ featureGroupDao
+ .updateFeatureGroup(featureGroup, addedEntitlementPools, removedEntitlementPools, addedLicenseKeyGroups, removedLicenseKeyGroups);
+ }
+
+ @Override
+ public FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup) {
+ return vendorLicenseFacade.getFeatureGroupModel(featureGroup);
+ }
+
+ @Override
+ public void deleteFeatureGroup(FeatureGroupEntity featureGroup) {
+ FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
+ VersioningUtil.validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
+ removeLicenseKeyGroupsToFeatureGroupsRef(retrieved.getLicenseKeyGroupIds(), featureGroup);
+ removeEntitlementPoolsToFeatureGroupsRef(retrieved.getEntitlementPoolIds(), featureGroup);
+ for (String licenceAgreementId : retrieved.getReferencingLicenseAgreements()) {
+ licenseAgreementDao
+ .removeFeatureGroup(new LicenseAgreementEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(), licenceAgreementId),
+ featureGroup.getId());
+ }
+ featureGroupDao.delete(featureGroup);
+ deleteUniqueName(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME, retrieved.getVendorLicenseModelId(),
+ retrieved.getVersion().toString(), retrieved.getName());
+ }
+
+ @Override
+ public Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version) {
+ return vendorLicenseFacade.listEntitlementPools(vlmId, version);
+ }
+
+ @Override
+ public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool) {
+ entitlementPool.setStartDate(getDate(entitlementPool.getStartDate(), EP_POOL_START_TIME));
+ entitlementPool.setExpiryDate(getDate(entitlementPool.getExpiryDate(), EP_POOL_EXPIRY_TIME));
+ validateCreateDate(entitlementPool.getStartDate(), entitlementPool.getExpiryDate(), entitlementPool.getVendorLicenseModelId());
+ return vendorLicenseFacade.createEntitlementPool(entitlementPool);
+ }
+
+ private String getDate(String date, String poolTime) {
+ return date != null ? (!date.trim().isEmpty() ? date + poolTime : null) : null;
+ }
+
+ private void validateCreateDate(String startDate, String expiryDate, String vendorLicenseModelId) {
+ //original logic allows both nulls
+ if (StringUtils.isEmpty(startDate) && StringUtils.isEmpty(expiryDate)) {
+ return;
}
- return false;
- }
- }
- return true;
- }
-
- @Override
- public Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId) {
- return vendorLicenseFacade.listLimits(vlmId, version, epLkgId);
- }
-
- @Override
- public void deleteLimit(LimitEntity limitEntity) {
- if (!isLimitPresent(limitEntity)) {
- VersioningUtil
- .validateEntityExistence(null, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
- }
- LimitEntity retrieved = limitDao.get(limitEntity);
- VersioningUtil
- .validateEntityExistence(retrieved, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
-
- limitDao.delete(limitEntity);
-
- updateParentForLimit(limitEntity);
- }
-
- @Override
- public void updateLimit(LimitEntity limit) {
- getLimit(limit);
- validateLimit(limit);
- LimitEntity retrieved = limitDao.get(limit);
- if(!retrieved.equals(limit)){
- vendorLicenseFacade.updateLimit(limit);
- updateParentForLimit(limit);
- }
- }
-
- private boolean isLimitPresent(LimitEntity limit) {
- return limitDao.isLimitPresent(limit);
- }
-
- @Override
- public LimitEntity getLimit(LimitEntity limitEntity) {
- if (!isLimitPresent(limitEntity)) {
- VersioningUtil
- .validateEntityExistence(null, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
- }
- LimitEntity retrieved = limitDao.get(limitEntity);
- VersioningUtil
- .validateEntityExistence(retrieved, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
- return retrieved;
- }
-
- /**
- * update Parent of limit (EP/LKG) versionuuid when limit is modified so that limit updates are
- * captured in VLM XML
- */
- private void updateParentForLimit(LimitEntity limit) {
- if ("EntitlementPool".equals(limit.getParent())) {
- EntitlementPoolEntity entitlementPoolEntity =
- entitlementPoolDao.get(new EntitlementPoolEntity(limit.getVendorLicenseModelId(),
- limit.getVersion(), limit.getEpLkgId()));
- entitlementPoolEntity.setVersionUuId(CommonMethods.nextUuId());
- entitlementPoolDao.update(entitlementPoolEntity);
- }
-
- if ("LicenseKeyGroup".equals(limit.getParent())) {
- LicenseKeyGroupEntity licenseKeyGroupEntity = licenseKeyGroupDao.get(
- new LicenseKeyGroupEntity(limit.getVendorLicenseModelId(), limit.getVersion(),
- limit.getEpLkgId()));
- licenseKeyGroupEntity.setVersionUuId(CommonMethods.nextUuId());
- licenseKeyGroupDao.update(licenseKeyGroupEntity);
- }
- }
-
- protected void addFeatureGroupsToLicenseAgreementRef(Set<String> featureGroupIds,
- LicenseAgreementEntity licenseAgreement) {
- if (featureGroupIds != null) {
- for (String featureGroupId : featureGroupIds) {
- featureGroupDao.addReferencingLicenseAgreement(
- new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
- licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId());
- }
- }
- }
-
- protected void removeFeatureGroupsToLicenseAgreementRef(Set<String> featureGroupIds,
- LicenseAgreementEntity licenseAgreement) {
- if (featureGroupIds != null) {
- for (String featureGroupId : featureGroupIds) {
- featureGroupDao.removeReferencingLicenseAgreement(
- new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
- licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId());
- }
- }
- }
-
- protected void addLicenseKeyGroupsToFeatureGroupsRef(Set<String> licenseKeyGroupIds,
- FeatureGroupEntity featureGroup) {
- if (licenseKeyGroupIds != null) {
- for (String licenseKeyGroupId : licenseKeyGroupIds) {
- licenseKeyGroupDao.addReferencingFeatureGroup(
- new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion(), licenseKeyGroupId), featureGroup.getId());
- }
- }
- }
-
- protected void removeLicenseKeyGroupsToFeatureGroupsRef(Set<String> licenseKeyGroupIds,
- FeatureGroupEntity featureGroup) {
- if (licenseKeyGroupIds != null) {
- for (String licenseKeyGroupId : licenseKeyGroupIds) {
- licenseKeyGroupDao.removeReferencingFeatureGroup(
- new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion(), licenseKeyGroupId), featureGroup.getId());
- }
- }
- }
-
- protected void addEntitlementPoolsToFeatureGroupsRef(Set<String> entitlementPoolIds,
- FeatureGroupEntity featureGroup) {
- if (entitlementPoolIds != null) {
- for (String entitlementPoolId : entitlementPoolIds) {
- entitlementPoolDao.addReferencingFeatureGroup(
- new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion(), entitlementPoolId), featureGroup.getId());
- }
- }
- }
-
- protected void removeEntitlementPoolsToFeatureGroupsRef(Set<String> entitlementPoolIds,
- FeatureGroupEntity featureGroup) {
- if (entitlementPoolIds != null) {
- for (String entitlementPoolId : entitlementPoolIds) {
- entitlementPoolDao.removeReferencingFeatureGroup(
- new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion(), entitlementPoolId), featureGroup.getId());
- }
- }
- }
-
- protected void updateUniqueName(String uniqueValueType, String oldName, String newName, String...
- context) {
- uniqueValueUtil
- .updateUniqueValue(uniqueValueType, oldName, newName, context);
- }
-
- protected void deleteUniqueName(String uniqueValueType, String... uniqueCombination) {
- uniqueValueUtil.deleteUniqueValue(uniqueValueType, uniqueCombination);
- }
+ Optional<LocalDate> parsedStartDate = parseLocalDate(startDate);
+ Optional<LocalDate> parsedExpiryDate = parseLocalDate(expiryDate);
+ if (!parsedStartDate.isPresent()) {
+ throw new CoreException(new InvalidDateErrorBuilder(vendorLicenseModelId).build());
+ }
+ if (!parsedExpiryDate.isPresent() && parsedStartDate.get().atStartOfDay().isBefore(LocalDate.now().atStartOfDay())) {
+ throw new CoreException(new InvalidDateErrorBuilder(vendorLicenseModelId).build());
+ }
+ if (parsedExpiryDate.isPresent() && isNotValidatStartAndExpiryDate(parsedStartDate.get(), parsedExpiryDate.get())) {
+ throw new CoreException(new InvalidDateErrorBuilder(vendorLicenseModelId).build());
+ }
+ }
+
+ private boolean isNotValidatStartAndExpiryDate(LocalDate parsedStartDate, LocalDate parsedExpiryDate) {
+ return parsedStartDate.atStartOfDay().isBefore(LocalDate.now().atStartOfDay()) || parsedExpiryDate.atStartOfDay()
+ .isEqual(parsedStartDate.atStartOfDay()) || parsedExpiryDate.isBefore(parsedStartDate);
+ }
+
+ private void validateUpdateDate(String startDate, String expiryDate, String vendorLicenseModelId) {
+ Optional<LocalDate> parsedStartDate = parseLocalDate(startDate);
+ Optional<LocalDate> parsedExpiryDate = parseLocalDate(expiryDate);
+ if (parsedStartDate.isPresent() && parsedExpiryDate.isPresent() && (
+ parsedExpiryDate.get().atStartOfDay().isEqual(parsedStartDate.get().atStartOfDay()) || parsedExpiryDate.get()
+ .isBefore(parsedStartDate.get()))) {
+ throw new CoreException(new InvalidDateErrorBuilder(vendorLicenseModelId).build());
+ }
+ if (startDate == null && expiryDate != null) {
+ throw new CoreException(new InvalidDateErrorBuilder(vendorLicenseModelId).build());
+ }
+ }
+
+ @Override
+ public void updateEntitlementPool(EntitlementPoolEntity entitlementPool) {
+ entitlementPool.setStartDate(getDate(entitlementPool.getStartDate(), EP_POOL_START_TIME));
+ entitlementPool.setExpiryDate(getDate(entitlementPool.getExpiryDate(), EP_POOL_EXPIRY_TIME));
+ validateUpdateDate(entitlementPool.getStartDate(), entitlementPool.getExpiryDate(), entitlementPool.getVendorLicenseModelId());
+ vendorLicenseFacade.updateEntitlementPool(entitlementPool);
+ }
+
+ @Override
+ public EntitlementPoolEntity getEntitlementPool(EntitlementPoolEntity entitlementPool) {
+ EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
+ VersioningUtil.validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
+ DateTimeFormatter targetFormatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ if (retrieved.getStartDate() != null) {
+ retrieved.setStartDate(LocalDate.parse(retrieved.getStartDate(), FORMATTER).format(targetFormatter));
+ }
+ if (retrieved.getExpiryDate() != null) {
+ retrieved.setExpiryDate(LocalDate.parse(retrieved.getExpiryDate(), FORMATTER).format(targetFormatter));
+ }
+ return retrieved;
+ }
+
+ @Override
+ public void deleteEntitlementPool(EntitlementPoolEntity entitlementPool) {
+ EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
+ VersioningUtil.validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
+ for (String referencingFeatureGroupId : retrieved.getReferencingFeatureGroups()) {
+ featureGroupDao.removeEntitlementPool(
+ new FeatureGroupEntity(entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion(), referencingFeatureGroupId),
+ entitlementPool.getId());
+ }
+ deleteChildLimits(entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion(), entitlementPool.getId());
+ entitlementPoolDao.delete(entitlementPool);
+ deleteUniqueName(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME, retrieved.getVendorLicenseModelId(),
+ retrieved.getVersion().toString(), retrieved.getName());
+ }
+
+ protected void deleteChildLimits(String vlmId, Version version, String epLkgId) {
+ Optional<Collection<LimitEntity>> limitEntities = Optional.ofNullable(listLimits(vlmId, version, epLkgId));
+ limitEntities.ifPresent(entities -> entities.forEach(this::deleteLimit));
+ }
+
+ @Override
+ public Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version) {
+ return vendorLicenseFacade.listLicenseKeyGroups(vlmId, version);
+ }
+
+ @Override
+ public LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
+ licenseKeyGroup.setStartDate(
+ licenseKeyGroup.getStartDate() != null ? (licenseKeyGroup.getStartDate().trim().length() != 0 ? licenseKeyGroup.getStartDate()
+ + EP_POOL_START_TIME : null) : null);
+ licenseKeyGroup.setExpiryDate(
+ licenseKeyGroup.getExpiryDate() != null ? (licenseKeyGroup.getExpiryDate().trim().length() != 0 ? licenseKeyGroup.getExpiryDate()
+ + EP_POOL_EXPIRY_TIME : null) : null);
+ validateCreateDate(licenseKeyGroup.getStartDate(), licenseKeyGroup.getExpiryDate(), licenseKeyGroup.getVendorLicenseModelId());
+ return vendorLicenseFacade.createLicenseKeyGroup(licenseKeyGroup);
+ }
+
+ @Override
+ public void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
+ licenseKeyGroup.setStartDate(
+ licenseKeyGroup.getStartDate() != null ? (licenseKeyGroup.getStartDate().trim().length() != 0 ? licenseKeyGroup.getStartDate()
+ + EP_POOL_START_TIME : null) : null);
+ licenseKeyGroup.setExpiryDate(
+ licenseKeyGroup.getExpiryDate() != null ? (licenseKeyGroup.getExpiryDate().trim().length() != 0 ? licenseKeyGroup.getExpiryDate()
+ + EP_POOL_EXPIRY_TIME : null) : null);
+ validateUpdateDate(licenseKeyGroup.getStartDate(), licenseKeyGroup.getExpiryDate(), licenseKeyGroup.getVendorLicenseModelId());
+ vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroup);
+ }
+
+ @Override
+ public LicenseKeyGroupEntity getLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
+ LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
+ VersioningUtil.validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
+ return retrieved;
+ }
+
+ @Override
+ public void deleteLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
+ LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
+ VersioningUtil.validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
+ for (String referencingFeatureGroupId : retrieved.getReferencingFeatureGroups()) {
+ featureGroupDao.removeLicenseKeyGroup(
+ new FeatureGroupEntity(licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion(), referencingFeatureGroupId),
+ licenseKeyGroup.getId());
+ }
+ deleteChildLimits(licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion(), licenseKeyGroup.getId());
+ licenseKeyGroupDao.delete(licenseKeyGroup);
+ deleteUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME, retrieved.getVendorLicenseModelId(),
+ retrieved.getVersion().toString(), retrieved.getName());
+ }
+
+ @Override
+ public LimitEntity createLimit(LimitEntity limit) {
+ validateLimit(limit);
+ LimitEntity createdLimit = vendorLicenseFacade.createLimit(limit);
+ updateParentForLimit(limit);
+ return createdLimit;
+ }
+
+ private void validateLimit(LimitEntity limit) {
+ Collection<LimitEntity> limitList = listLimits(limit.getVendorLicenseModelId(), limit.getVersion(), limit.getEpLkgId());
+ if (!isLimitNameUnique(limitList, limit.getName(), limit.getType(), limit.getId())) {
+ final ErrorCode duplicateLimitNameErrorBuilder = LimitErrorBuilder.getDuplicateNameErrorbuilder(limit.getName(), limit.getType().name());
+ throw new CoreException(duplicateLimitNameErrorBuilder);
+ }
+ }
+
+ private boolean isLimitNameUnique(Collection<LimitEntity> limitList, String name, LimitType type, String id) {
+ for (LimitEntity limit : limitList) {
+ if (limit.getName().equalsIgnoreCase(name) && limit.getType().name().equalsIgnoreCase(type.name())) {
+ if (id != null && limit.getId().equals(id)) {
+ continue;
+ }
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId) {
+ return vendorLicenseFacade.listLimits(vlmId, version, epLkgId);
+ }
+
+ @Override
+ public void deleteLimit(LimitEntity limitEntity) {
+ if (!isLimitPresent(limitEntity)) {
+ VersioningUtil.validateEntityExistence(null, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
+ }
+ LimitEntity retrieved = limitDao.get(limitEntity);
+ VersioningUtil.validateEntityExistence(retrieved, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
+ limitDao.delete(limitEntity);
+ updateParentForLimit(limitEntity);
+ }
+
+ @Override
+ public void updateLimit(LimitEntity limit) {
+ getLimit(limit);
+ validateLimit(limit);
+ LimitEntity retrieved = limitDao.get(limit);
+ if (!retrieved.equals(limit)) {
+ vendorLicenseFacade.updateLimit(limit);
+ updateParentForLimit(limit);
+ }
+ }
+
+ private boolean isLimitPresent(LimitEntity limit) {
+ return limitDao.isLimitPresent(limit);
+ }
+
+ @Override
+ public LimitEntity getLimit(LimitEntity limitEntity) {
+ if (!isLimitPresent(limitEntity)) {
+ VersioningUtil.validateEntityExistence(null, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
+ }
+ LimitEntity retrieved = limitDao.get(limitEntity);
+ VersioningUtil.validateEntityExistence(retrieved, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
+ return retrieved;
+ }
+
+ /**
+ * update Parent of limit (EP/LKG) versionuuid when limit is modified so that limit updates are captured in VLM XML
+ */
+ private void updateParentForLimit(LimitEntity limit) {
+ if ("EntitlementPool".equals(limit.getParent())) {
+ EntitlementPoolEntity entitlementPoolEntity = entitlementPoolDao
+ .get(new EntitlementPoolEntity(limit.getVendorLicenseModelId(), limit.getVersion(), limit.getEpLkgId()));
+ entitlementPoolEntity.setVersionUuId(CommonMethods.nextUuId());
+ entitlementPoolDao.update(entitlementPoolEntity);
+ }
+ if ("LicenseKeyGroup".equals(limit.getParent())) {
+ LicenseKeyGroupEntity licenseKeyGroupEntity = licenseKeyGroupDao
+ .get(new LicenseKeyGroupEntity(limit.getVendorLicenseModelId(), limit.getVersion(), limit.getEpLkgId()));
+ licenseKeyGroupEntity.setVersionUuId(CommonMethods.nextUuId());
+ licenseKeyGroupDao.update(licenseKeyGroupEntity);
+ }
+ }
+
+ protected void addFeatureGroupsToLicenseAgreementRef(Set<String> featureGroupIds, LicenseAgreementEntity licenseAgreement) {
+ if (featureGroupIds != null) {
+ for (String featureGroupId : featureGroupIds) {
+ featureGroupDao.addReferencingLicenseAgreement(
+ new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion(), featureGroupId),
+ licenseAgreement.getId());
+ }
+ }
+ }
+
+ protected void removeFeatureGroupsToLicenseAgreementRef(Set<String> featureGroupIds, LicenseAgreementEntity licenseAgreement) {
+ if (featureGroupIds != null) {
+ for (String featureGroupId : featureGroupIds) {
+ featureGroupDao.removeReferencingLicenseAgreement(
+ new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion(), featureGroupId),
+ licenseAgreement.getId());
+ }
+ }
+ }
+
+ protected void addLicenseKeyGroupsToFeatureGroupsRef(Set<String> licenseKeyGroupIds, FeatureGroupEntity featureGroup) {
+ if (licenseKeyGroupIds != null) {
+ for (String licenseKeyGroupId : licenseKeyGroupIds) {
+ licenseKeyGroupDao.addReferencingFeatureGroup(
+ new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(), licenseKeyGroupId),
+ featureGroup.getId());
+ }
+ }
+ }
+
+ protected void removeLicenseKeyGroupsToFeatureGroupsRef(Set<String> licenseKeyGroupIds, FeatureGroupEntity featureGroup) {
+ if (licenseKeyGroupIds != null) {
+ for (String licenseKeyGroupId : licenseKeyGroupIds) {
+ licenseKeyGroupDao.removeReferencingFeatureGroup(
+ new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(), licenseKeyGroupId),
+ featureGroup.getId());
+ }
+ }
+ }
+
+ protected void addEntitlementPoolsToFeatureGroupsRef(Set<String> entitlementPoolIds, FeatureGroupEntity featureGroup) {
+ if (entitlementPoolIds != null) {
+ for (String entitlementPoolId : entitlementPoolIds) {
+ entitlementPoolDao.addReferencingFeatureGroup(
+ new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(), entitlementPoolId),
+ featureGroup.getId());
+ }
+ }
+ }
+
+ protected void removeEntitlementPoolsToFeatureGroupsRef(Set<String> entitlementPoolIds, FeatureGroupEntity featureGroup) {
+ if (entitlementPoolIds != null) {
+ for (String entitlementPoolId : entitlementPoolIds) {
+ entitlementPoolDao.removeReferencingFeatureGroup(
+ new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(), entitlementPoolId),
+ featureGroup.getId());
+ }
+ }
+ }
+
+ protected void updateUniqueName(String uniqueValueType, String oldName, String newName, String... context) {
+ uniqueValueUtil.updateUniqueValue(uniqueValueType, oldName, newName, context);
+ }
+
+ protected void deleteUniqueName(String uniqueValueType, String... uniqueCombination) {
+ uniqueValueUtil.deleteUniqueValue(uniqueValueType, uniqueCombination);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManager.java
index 7ac636879b..7cdec000b3 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManager.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,24 +17,21 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
+import java.util.Collection;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Collection;
-
public interface ComponentDependencyModelManager {
- Collection<ComponentDependencyModelEntity> list(String vspId, Version version);
+ Collection<ComponentDependencyModelEntity> list(String vspId, Version version);
- ComponentDependencyModelEntity createComponentDependency(ComponentDependencyModelEntity entity,
- String vspId, Version version);
+ ComponentDependencyModelEntity createComponentDependency(ComponentDependencyModelEntity entity, String vspId, Version version);
- void delete(String vspId, Version version, String dependencyId);
+ void delete(String vspId, Version version, String dependencyId);
- void update(ComponentDependencyModelEntity entity);
+ void update(ComponentDependencyModelEntity entity);
- ComponentDependencyModelEntity get(String vspId, Version version, String dependencyId);
+ ComponentDependencyModelEntity get(String vspId, Version version, String dependencyId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManagerFactory.java
index bd5cd45561..ee2c447e20 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManagerFactory.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,16 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
-
import org.openecomp.core.factory.api.AbstractComponentFactory;
-public abstract class ComponentDependencyModelManagerFactory extends
- AbstractComponentFactory<ComponentDependencyModelManager> {
+public abstract class ComponentDependencyModelManagerFactory extends AbstractComponentFactory<ComponentDependencyModelManager> {
- public static ComponentDependencyModelManagerFactory getInstance() {
- return getInstance(ComponentDependencyModelManagerFactory.class);
- }
+ public static ComponentDependencyModelManagerFactory getInstance() {
+ return getInstance(ComponentDependencyModelManagerFactory.class);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java
index 413529882d..a9a0a0377e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java
@@ -17,9 +17,9 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
+import java.util.Collection;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
@@ -27,27 +27,23 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Collection;
-
public interface ComponentManager {
- Collection<ComponentEntity> listComponents(String vspId, Version version);
+ Collection<ComponentEntity> listComponents(String vspId, Version version);
- void deleteComponents(String vspId, Version version);
+ void deleteComponents(String vspId, Version version);
- ComponentEntity createComponent(ComponentEntity componentEntity);
+ ComponentEntity createComponent(ComponentEntity componentEntity);
- CompositionEntityValidationData updateComponent(ComponentEntity componentEntity);
+ CompositionEntityValidationData updateComponent(ComponentEntity componentEntity);
- CompositionEntityResponse<ComponentData> getComponent(String vspId, Version version,
- String componentId);
+ CompositionEntityResponse<ComponentData> getComponent(String vspId, Version version, String componentId);
- void deleteComponent(String vspId, Version version, String componentId);
+ void deleteComponent(String vspId, Version version, String componentId);
- QuestionnaireResponse getQuestionnaire(String vspId, Version version, String componentId);
+ QuestionnaireResponse getQuestionnaire(String vspId, Version version, String componentId);
- void updateQuestionnaire(String vspId, Version version, String componentId,
- String questionnaireData);
+ void updateQuestionnaire(String vspId, Version version, String componentId, String questionnaireData);
- void validateComponentExistence(String vspId, Version version, String componentId);
+ void validateComponentExistence(String vspId, Version version, String componentId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManagerFactory.java
index 9af238e4e3..154f0a8c44 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManagerFactory.java
@@ -17,14 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
import org.openecomp.core.factory.api.AbstractComponentFactory;
public abstract class ComponentManagerFactory extends AbstractComponentFactory<ComponentManager> {
- public static ComponentManagerFactory getInstance() {
- return getInstance(ComponentManagerFactory.class);
- }
+ public static ComponentManagerFactory getInstance() {
+ return getInstance(ComponentManagerFactory.class);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/CompositionEntityDataManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/CompositionEntityDataManager.java
index 2cf4063319..7899dd2bf1 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/CompositionEntityDataManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/CompositionEntityDataManager.java
@@ -13,10 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.*;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId;
@@ -25,44 +31,36 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTempl
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
public interface CompositionEntityDataManager {
- Map<CompositionEntityId, Collection<String>> validateEntitiesQuestionnaire();
-
- void addEntity(CompositionEntity entity, SchemaTemplateInput schemaTemplateInput);
+ Map<CompositionEntityId, Collection<String>> validateEntitiesQuestionnaire();
- CompositionEntityValidationData validateEntity(CompositionEntity entity,
- SchemaTemplateContext schemaTemplateContext,
- SchemaTemplateInput schemaTemplateInput);
+ void addEntity(CompositionEntity entity, SchemaTemplateInput schemaTemplateInput);
- void buildTrees();
+ CompositionEntityValidationData validateEntity(CompositionEntity entity, SchemaTemplateContext schemaTemplateContext,
+ SchemaTemplateInput schemaTemplateInput);
- void addErrorsToTrees(Map<CompositionEntityId, Collection<String>> errors);
+ void buildTrees();
- Set<CompositionEntityValidationData> getEntityListWithErrors();
+ void addErrorsToTrees(Map<CompositionEntityId, Collection<String>> errors);
- Collection<CompositionEntityValidationData> getTrees();
+ Set<CompositionEntityValidationData> getEntityListWithErrors();
- void saveCompositionData(String vspId, Version version, CompositionData compositionData);
+ Collection<CompositionEntityValidationData> getTrees();
- Set<CompositionEntityValidationData> getAllErrorsByVsp(String vspId);
+ void saveCompositionData(String vspId, Version version, CompositionData compositionData);
- ComponentEntity createComponent(ComponentEntity component, boolean isManualVsp);
+ Set<CompositionEntityValidationData> getAllErrorsByVsp(String vspId);
- NicEntity createNic(NicEntity nic);
+ ComponentEntity createComponent(ComponentEntity component, boolean isManualVsp);
- DeploymentFlavorEntity createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavor);
+ NicEntity createNic(NicEntity nic);
- ImageEntity createImage(ImageEntity image);
+ DeploymentFlavorEntity createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavor);
- void saveComputesFlavorByComponent(String vspId, Version version, Component component,
- String componentId);
+ ImageEntity createImage(ImageEntity image);
- void saveImagesByComponent(String vspId, Version version, Component component,
- String componentId);
+ void saveComputesFlavorByComponent(String vspId, Version version, Component component, String componentId);
+ void saveImagesByComponent(String vspId, Version version, Component component, String componentId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/CompositionEntityDataManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/CompositionEntityDataManagerFactory.java
index be4f187c15..2d09bb2601 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/CompositionEntityDataManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/CompositionEntityDataManagerFactory.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,15 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
import org.openecomp.core.factory.api.AbstractComponentFactory;
-public abstract class CompositionEntityDataManagerFactory extends
- AbstractComponentFactory<CompositionEntityDataManager> {
+public abstract class CompositionEntityDataManagerFactory extends AbstractComponentFactory<CompositionEntityDataManager> {
- public static CompositionEntityDataManagerFactory getInstance() {
- return getInstance(CompositionEntityDataManagerFactory.class);
- }
+ public static CompositionEntityDataManagerFactory getInstance() {
+ return getInstance(CompositionEntityDataManagerFactory.class);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java
index ac903dd3da..bc531bc73f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,9 +17,9 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
+import java.util.Collection;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.ListComputeResponse;
@@ -28,24 +28,19 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEnti
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Collection;
-
public interface ComputeManager {
- Collection<ListComputeResponse> listComputes(String vspId, Version version, String componentId);
+ Collection<ListComputeResponse> listComputes(String vspId, Version version, String componentId);
- ComputeEntity createCompute(ComputeEntity compute);
+ ComputeEntity createCompute(ComputeEntity compute);
- CompositionEntityResponse<ComputeData> getCompute(String vspId, Version version,
- String componentId, String computeFlavorId);
+ CompositionEntityResponse<ComputeData> getCompute(String vspId, Version version, String componentId, String computeFlavorId);
- QuestionnaireResponse getComputeQuestionnaire(String vspId, Version version, String componentId,
- String computeFlavorId);
+ QuestionnaireResponse getComputeQuestionnaire(String vspId, Version version, String componentId, String computeFlavorId);
- void updateComputeQuestionnaire(String vspId, Version version, String componentId,
- String computeId, String questionnaireData);
+ void updateComputeQuestionnaire(String vspId, Version version, String componentId, String computeId, String questionnaireData);
- CompositionEntityValidationData updateCompute(ComputeEntity compute);
+ CompositionEntityValidationData updateCompute(ComputeEntity compute);
- void deleteCompute(String vspId, Version version, String componentId, String computeFlavorId);
+ void deleteCompute(String vspId, Version version, String componentId, String computeFlavorId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManagerFactory.java
index 063bae1237..cc09e3323a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManagerFactory.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
import org.openecomp.core.factory.api.AbstractComponentFactory;
@@ -25,6 +24,6 @@ import org.openecomp.core.factory.api.AbstractComponentFactory;
public abstract class ComputeManagerFactory extends AbstractComponentFactory<ComputeManager> {
public static ComputeManagerFactory getInstance() {
- return getInstance(ComputeManagerFactory.class);
+ return getInstance(ComputeManagerFactory.class);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java
index b36c6f0864..e506bc019b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,34 +17,26 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
-
+import java.util.Collection;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Collection;
-
public interface DeploymentFlavorManager {
+ DeploymentFlavorEntity createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity);
- DeploymentFlavorEntity createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity);
-
- Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version);
-
- CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavor(String vspId, Version version,
- String deploymentFlavorId);
+ Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version);
- CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavorSchema(String vspId,
- Version version);
+ CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavor(String vspId, Version version, String deploymentFlavorId);
- void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId);
+ CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavorSchema(String vspId, Version version);
- CompositionEntityValidationData updateDeploymentFlavor(
- DeploymentFlavorEntity deploymentFlavorEntity);
+ void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId);
+ CompositionEntityValidationData updateDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManagerFactory.java
index 97ae62978d..cc99db62d5 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManagerFactory.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,16 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
-
import org.openecomp.core.factory.api.AbstractComponentFactory;
-public abstract class DeploymentFlavorManagerFactory extends
- AbstractComponentFactory<DeploymentFlavorManager> {
+public abstract class DeploymentFlavorManagerFactory extends AbstractComponentFactory<DeploymentFlavorManager> {
- public static DeploymentFlavorManagerFactory getInstance() {
- return getInstance(DeploymentFlavorManagerFactory.class);
- }
+ public static DeploymentFlavorManagerFactory getInstance() {
+ return getInstance(DeploymentFlavorManagerFactory.class);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java
index d1a8662821..f106c2a2ef 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,9 +17,9 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
+import java.util.Collection;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
@@ -27,25 +27,21 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEnti
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Collection;
-
public interface ImageManager {
- ImageEntity createImage(ImageEntity imageEntity);
- CompositionEntityResponse<Image> getImageSchema(String vspId);
+ ImageEntity createImage(ImageEntity imageEntity);
+
+ CompositionEntityResponse<Image> getImageSchema(String vspId);
- Collection<ImageEntity> listImages(String vspId, Version version, String componentId);
+ Collection<ImageEntity> listImages(String vspId, Version version, String componentId);
- CompositionEntityResponse<Image> getImage(String vspId, Version version, String componentId,
- String imageId);
+ CompositionEntityResponse<Image> getImage(String vspId, Version version, String componentId, String imageId);
- QuestionnaireResponse getImageQuestionnaire(String vspId, Version version, String componentId,
- String imageId);
+ QuestionnaireResponse getImageQuestionnaire(String vspId, Version version, String componentId, String imageId);
- void deleteImage(String vspId, Version version, String componentId, String imageId);
+ void deleteImage(String vspId, Version version, String componentId, String imageId);
- CompositionEntityValidationData updateImage(ImageEntity imageEntity);
+ CompositionEntityValidationData updateImage(ImageEntity imageEntity);
- void updateImageQuestionnaire(String vspId, Version version, String componentId, String imageId,
- String questionnaireData);
+ void updateImageQuestionnaire(String vspId, Version version, String componentId, String imageId, String questionnaireData);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManagerFactory.java
index 2ee014bb28..1caad874f1 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManagerFactory.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,15 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
import org.openecomp.core.factory.api.AbstractComponentFactory;
public abstract class ImageManagerFactory extends AbstractComponentFactory<ImageManager> {
- public static ImageManagerFactory getInstance() {
- return getInstance(ImageManagerFactory.class);
- }
+ public static ImageManagerFactory getInstance() {
+ return getInstance(ImageManagerFactory.class);
+ }
}
-
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java
index 4d8c861b9d..292723e1fa 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
import org.openecomp.sdc.generator.datatypes.tosca.VspModelInfo;
@@ -26,7 +25,7 @@ import org.openecomp.sdc.versioning.dao.types.Version;
public interface ManualVspToscaManager {
- VspModelInfo gatherVspInformation(String vspId, Version version);
+ VspModelInfo gatherVspInformation(String vspId, Version version);
- ToscaServiceModel generateToscaModel(VspModelInfo vspModelInfo);
+ ToscaServiceModel generateToscaModel(VspModelInfo vspModelInfo);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java
index 36f06507dc..0bc55b2ff4 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java
@@ -17,21 +17,18 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
+import java.io.InputStream;
import org.openecomp.core.enrichment.types.MonitoringUploadType;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MonitoringUploadStatus;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.io.InputStream;
-
public interface MonitoringUploadsManager {
- void delete(String vspId, Version version, String componentId,
- MonitoringUploadType monitoringUploadType);
- void upload(InputStream object, String filename, String vspId, Version version,
- String componentId, MonitoringUploadType monitoringUploadType);
+ void delete(String vspId, Version version, String componentId, MonitoringUploadType monitoringUploadType);
+
+ void upload(InputStream object, String filename, String vspId, Version version, String componentId, MonitoringUploadType monitoringUploadType);
- MonitoringUploadStatus listFilenames(String vspId, Version version, String componentId);
+ MonitoringUploadStatus listFilenames(String vspId, Version version, String componentId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManagerFactory.java
index 9850b2e19b..db41837222 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManagerFactory.java
@@ -17,15 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
import org.openecomp.core.factory.api.AbstractComponentFactory;
-public abstract class MonitoringUploadsManagerFactory
- extends AbstractComponentFactory<MonitoringUploadsManager> {
+public abstract class MonitoringUploadsManagerFactory extends AbstractComponentFactory<MonitoringUploadsManager> {
- public static MonitoringUploadsManagerFactory getInstance() {
- return getInstance(MonitoringUploadsManagerFactory.class);
- }
+ public static MonitoringUploadsManagerFactory getInstance() {
+ return getInstance(MonitoringUploadsManagerFactory.class);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManager.java
index fa740690b7..837f7803d9 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManager.java
@@ -17,25 +17,24 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
+import java.util.Collection;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Collection;
-
public interface NetworkManager {
- Collection<NetworkEntity> listNetworks(String vspId, Version version);
- NetworkEntity createNetwork(NetworkEntity network);
+ Collection<NetworkEntity> listNetworks(String vspId, Version version);
+
+ NetworkEntity createNetwork(NetworkEntity network);
- CompositionEntityValidationData updateNetwork(NetworkEntity networkEntity);
+ CompositionEntityValidationData updateNetwork(NetworkEntity networkEntity);
- CompositionEntityResponse<Network> getNetwork(String vspId, Version version, String networkId);
+ CompositionEntityResponse<Network> getNetwork(String vspId, Version version, String networkId);
- void deleteNetwork(String vspId, Version version, String networkId);
+ void deleteNetwork(String vspId, Version version, String networkId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManagerFactory.java
index a0b7465235..1c230a04bf 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManagerFactory.java
@@ -17,14 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
import org.openecomp.core.factory.api.AbstractComponentFactory;
public abstract class NetworkManagerFactory extends AbstractComponentFactory<NetworkManager> {
- public static NetworkManagerFactory getInstance() {
- return getInstance(NetworkManagerFactory.class);
- }
+ public static NetworkManagerFactory getInstance() {
+ return getInstance(NetworkManagerFactory.class);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java
index b055d97ef3..3a600f346d 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java
@@ -17,9 +17,9 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
+import java.util.Collection;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
@@ -27,24 +27,19 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEnti
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Collection;
-
public interface NicManager {
- Collection<NicEntity> listNics(String vspId, Version version, String componentId);
+ Collection<NicEntity> listNics(String vspId, Version version, String componentId);
- NicEntity createNic(NicEntity nic);
+ NicEntity createNic(NicEntity nic);
- CompositionEntityValidationData updateNic(NicEntity nicEntity);
+ CompositionEntityValidationData updateNic(NicEntity nicEntity);
- CompositionEntityResponse<Nic> getNic(String vspId, Version version, String componentId,
- String nicId);
+ CompositionEntityResponse<Nic> getNic(String vspId, Version version, String componentId, String nicId);
- void deleteNic(String vspId, Version version, String componentId, String nicId);
+ void deleteNic(String vspId, Version version, String componentId, String nicId);
- QuestionnaireResponse getNicQuestionnaire(String vspId, Version version, String componentId,
- String nicId);
+ QuestionnaireResponse getNicQuestionnaire(String vspId, Version version, String componentId, String nicId);
- void updateNicQuestionnaire(String vspId, Version version, String componentId, String nicId,
- String questionnaireData);
+ void updateNicQuestionnaire(String vspId, Version version, String componentId, String nicId, String questionnaireData);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManagerFactory.java
index 212619ce87..2749fee17f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManagerFactory.java
@@ -17,14 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
import org.openecomp.core.factory.api.AbstractComponentFactory;
public abstract class NicManagerFactory extends AbstractComponentFactory<NicManager> {
- public static NicManagerFactory getInstance() {
- return getInstance(NicManagerFactory.class);
- }
+ public static NicManagerFactory getInstance() {
+ return getInstance(NicManagerFactory.class);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java
index 5cf66874c4..f1c6aa5209 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
import java.io.IOException;
@@ -30,18 +29,17 @@ import org.openecomp.sdc.versioning.dao.types.Version;
public interface OrchestrationTemplateCandidateManager {
- OrchestrationTemplateActionResponse process(String vspId, Version version);
+ OrchestrationTemplateActionResponse process(String vspId, Version version);
- Optional<FilesDataStructure> getFilesDataStructure(String vspId, Version version);
+ Optional<FilesDataStructure> getFilesDataStructure(String vspId, Version version);
- ValidationResponse updateFilesDataStructure(String vspId, Version version,
- FilesDataStructure fileDataStructure);
+ ValidationResponse updateFilesDataStructure(String vspId, Version version, FilesDataStructure fileDataStructure);
- Optional<Pair<String, byte[]>> get(String vspId, Version version) throws IOException;
+ Optional<Pair<String, byte[]>> get(String vspId, Version version) throws IOException;
- Optional<OrchestrationTemplateCandidateData> getInfo(String vspId, Version version);
+ Optional<OrchestrationTemplateCandidateData> getInfo(String vspId, Version version);
- void abort(String vspId, Version version);
+ void abort(String vspId, Version version);
- UploadFileResponse upload(final VspDetails vspDetails, final OnboardPackageInfo onboardPackageInfo);
+ UploadFileResponse upload(final VspDetails vspDetails, final OnboardPackageInfo onboardPackageInfo);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManagerFactory.java
index b38355b8e9..8a5fe05d0d 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManagerFactory.java
@@ -17,15 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
import org.openecomp.core.factory.api.AbstractComponentFactory;
-public abstract class OrchestrationTemplateCandidateManagerFactory
- extends AbstractComponentFactory<OrchestrationTemplateCandidateManager> {
+public abstract class OrchestrationTemplateCandidateManagerFactory extends AbstractComponentFactory<OrchestrationTemplateCandidateManager> {
- public static OrchestrationTemplateCandidateManagerFactory getInstance() {
- return getInstance(OrchestrationTemplateCandidateManagerFactory.class);
- }
+ public static OrchestrationTemplateCandidateManagerFactory getInstance() {
+ return getInstance(OrchestrationTemplateCandidateManagerFactory.class);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java
index 979eea0fb8..c10a4c733c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java
@@ -17,33 +17,31 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
import java.io.File;
import java.io.InputStream;
import java.util.Collection;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
+import org.openecomp.sdc.versioning.dao.types.Version;
public interface ProcessManager {
- Collection<ProcessEntity> listProcesses(String vspId, Version version, String componentId);
- void deleteProcesses(String vspId, Version version, String componentId);
+ Collection<ProcessEntity> listProcesses(String vspId, Version version, String componentId);
+
+ void deleteProcesses(String vspId, Version version, String componentId);
- ProcessEntity createProcess(ProcessEntity processEntity);
+ ProcessEntity createProcess(ProcessEntity processEntity);
- ProcessEntity getProcess(String vspId, Version version, String componentId, String processId);
+ ProcessEntity getProcess(String vspId, Version version, String componentId, String processId);
- void updateProcess(ProcessEntity processEntity);
+ void updateProcess(ProcessEntity processEntity);
- void deleteProcess(String vspId, Version version, String componentId, String processId);
+ void deleteProcess(String vspId, Version version, String componentId, String processId);
- File getProcessArtifact(String vspId, Version version, String componentId, String processId);
+ File getProcessArtifact(String vspId, Version version, String componentId, String processId);
- void deleteProcessArtifact(String vspId, Version version, String componentId, String processId);
+ void deleteProcessArtifact(String vspId, Version version, String componentId, String processId);
- void uploadProcessArtifact(InputStream uploadFile, String fileName, String vspId,
- Version version, String componentId, String processId);
+ void uploadProcessArtifact(InputStream uploadFile, String fileName, String vspId, Version version, String componentId, String processId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManagerFactory.java
index f8d1038ca2..578e36778e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManagerFactory.java
@@ -17,14 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
import org.openecomp.core.factory.api.AbstractComponentFactory;
public abstract class ProcessManagerFactory extends AbstractComponentFactory<ProcessManager> {
- public static ProcessManagerFactory getInstance() {
- return getInstance(ProcessManagerFactory.class);
- }
+ public static ProcessManagerFactory getInstance() {
+ return getInstance(ProcessManagerFactory.class);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
index 2339fa0921..6a92dbb209 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
@@ -13,9 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
import org.apache.commons.lang3.tuple.Pair;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
@@ -27,13 +32,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
public interface VendorSoftwareProductManager {
VspDetails createVsp(VspDetails vspDetails);
@@ -48,12 +46,10 @@ public interface VendorSoftwareProductManager {
Map<String, List<ErrorMessage>> compile(String vspId, Version version);
-
QuestionnaireResponse getVspQuestionnaire(String vspId, Version version);
void updateVspQuestionnaire(String vspId, Version version, String questionnaireData);
-
byte[] getOrchestrationTemplateFile(String vspId, Version version);
OrchestrationTemplateEntity getOrchestrationTemplateInfo(String vspId, Version version);
@@ -64,7 +60,6 @@ public interface VendorSoftwareProductManager {
List<PackageInfo> listPackages(String category, String subCategory);
-
File getTranslatedFile(String vspId, Version version);
File getInformationArtifact(String vspId, Version version);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VspManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VspManagerFactory.java
index a2f186428a..ac03524a12 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VspManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VspManagerFactory.java
@@ -17,15 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct;
import org.openecomp.core.factory.api.AbstractComponentFactory;
-public abstract class VspManagerFactory
- extends AbstractComponentFactory<VendorSoftwareProductManager> {
+public abstract class VspManagerFactory extends AbstractComponentFactory<VendorSoftwareProductManager> {
- public static VspManagerFactory getInstance() {
- return getInstance(VspManagerFactory.class);
- }
+ public static VspManagerFactory getInstance() {
+ return getInstance(VspManagerFactory.class);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java
index 249ad1cb28..c3869198b1 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java
@@ -13,60 +13,55 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.CYCLIC_DEPENDENCY_IN_COMPONENTS;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.INVALID_COMPONENT_RELATION_TYPE;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NO_SOURCE_COMPONENT;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.SAME_SOURCE_TARGET_COMPONENT;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.*;
-
public class ComponentDependencyModelErrorBuilder {
- private static final String CYCLIC_DEPENDENCY_COMPONENT_MSG = "Cyclic dependency exists between"
- + " components.";
-
- private static final String INVALID_REALTION_TYPE_MSG = "Invalid relation type for components.";
-
- private static final String NO_SOURCE_COMPONENT_MSG = "Source component is mandatory.";
-
- private static final String SOURCE_TARGET_COMPONENT_EQUAL_MSG = "Source and target components "
- + "are same.";
-
- private ComponentDependencyModelErrorBuilder(){
+ private static final String CYCLIC_DEPENDENCY_COMPONENT_MSG = "Cyclic dependency exists between" + " components.";
+ private static final String INVALID_REALTION_TYPE_MSG = "Invalid relation type for components.";
+ private static final String NO_SOURCE_COMPONENT_MSG = "Source component is mandatory.";
+ private static final String SOURCE_TARGET_COMPONENT_EQUAL_MSG = "Source and target components " + "are same.";
- }
+ private ComponentDependencyModelErrorBuilder() {
+ }
- public static ErrorCode getCyclicDependencyComponentErrorBuilder() {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(CYCLIC_DEPENDENCY_IN_COMPONENTS);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(CYCLIC_DEPENDENCY_COMPONENT_MSG);
- return builder.build();
- }
+ public static ErrorCode getCyclicDependencyComponentErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(CYCLIC_DEPENDENCY_IN_COMPONENTS);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(CYCLIC_DEPENDENCY_COMPONENT_MSG);
+ return builder.build();
+ }
- public static ErrorCode getInvalidRelationTypeErrorBuilder() {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(INVALID_COMPONENT_RELATION_TYPE);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(INVALID_REALTION_TYPE_MSG);
- return builder.build();
- }
+ public static ErrorCode getInvalidRelationTypeErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(INVALID_COMPONENT_RELATION_TYPE);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(INVALID_REALTION_TYPE_MSG);
+ return builder.build();
+ }
- public static ErrorCode getNoSourceComponentErrorBuilder() {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(NO_SOURCE_COMPONENT);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(NO_SOURCE_COMPONENT_MSG);
- return builder.build();
- }
+ public static ErrorCode getNoSourceComponentErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(NO_SOURCE_COMPONENT);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(NO_SOURCE_COMPONENT_MSG);
+ return builder.build();
+ }
- public static ErrorCode getSourceTargetComponentEqualErrorBuilder() {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(SAME_SOURCE_TARGET_COMPONENT);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(SOURCE_TARGET_COMPONENT_EQUAL_MSG);
- return builder.build();
- }
+ public static ErrorCode getSourceTargetComponentEqualErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(SAME_SOURCE_TARGET_COMPONENT);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(SOURCE_TARGET_COMPONENT_EQUAL_MSG);
+ return builder.build();
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentErrorBuilder.java
index 74f4fd2a13..0271020c09 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentErrorBuilder.java
@@ -13,28 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-
public class ComponentErrorBuilder {
- private static final String VFC_INVALID_MISSING_IMAGE_MSG =
- "All VFC need to have atleast a single Image specified. Please fix the VFC Images and re-submit the VSP";
-
- private ComponentErrorBuilder(){
-
- }
+ private static final String VFC_INVALID_MISSING_IMAGE_MSG = "All VFC need to have atleast a single Image specified. Please fix the VFC Images and re-submit the VSP";
+ private ComponentErrorBuilder() {
+ }
- public static ErrorCode vfcMissingImageErrorBuilder() {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(VendorSoftwareProductErrorCodes.VFC_INVALID);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(VFC_INVALID_MISSING_IMAGE_MSG);
- return builder.build();
- }
+ public static ErrorCode vfcMissingImageErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.VFC_INVALID);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(VFC_INVALID_MISSING_IMAGE_MSG);
+ return builder.build();
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CompositionEditNotAllowedErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CompositionEditNotAllowedErrorBuilder.java
index 4e4de2279e..fbb25dc3b3 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CompositionEditNotAllowedErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CompositionEditNotAllowedErrorBuilder.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,41 +17,37 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.versioning.dao.types.Version;
-
public class CompositionEditNotAllowedErrorBuilder {
- private static final String VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG =
- "Composition entities may not be created / deleted for Vendor Software Product %s, version %s"
- + "whose entities were uploaded";
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- /**
- * Instantiates a new error builder.
- *
- * @param vendorSoftwareProductId the vendor software product id
- * @param version the version
- */
- public CompositionEditNotAllowedErrorBuilder(String vendorSoftwareProductId, Version version) {
- builder.withId(VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(
- String.format(VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG, vendorSoftwareProductId,
- version == null ? null : version.toString()));
+ private static final String VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG =
+ "Composition entities may not be created / deleted for Vendor Software Product %s, version %s" + "whose entities were uploaded";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- }
+ /**
+ * Instantiates a new error builder.
+ *
+ * @param vendorSoftwareProductId the vendor software product id
+ * @param version the version
+ */
+ public CompositionEditNotAllowedErrorBuilder(String vendorSoftwareProductId, Version version) {
+ builder.withId(VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder
+ .withMessage(String.format(VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG, vendorSoftwareProductId, version == null ? null : version.toString()));
+ }
- /**
- * Build error code.
- *
- * @return the error code
- */
- public ErrorCode build() {
- return builder.build();
- }
+ /**
+ * Build error code.
+ *
+ * @return the error code
+ */
+ public ErrorCode build() {
+ return builder.build();
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComputeErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComputeErrorBuilder.java
index 5250b971ac..83cc92c119 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComputeErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComputeErrorBuilder.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
import org.openecomp.sdc.common.errors.ErrorCategory;
@@ -23,11 +22,10 @@ import org.openecomp.sdc.common.errors.ErrorCode;
* The Compute error builder.
*/
public class ComputeErrorBuilder {
- private static final String COMPUTE_NAME_FORMAT_MSG = "Field does not conform to predefined criteria"
- + ": name : must match %s";
- private ComputeErrorBuilder(){
+ private static final String COMPUTE_NAME_FORMAT_MSG = "Field does not conform to predefined criteria" + ": name : must match %s";
+ private ComputeErrorBuilder() {
}
/**
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CreatePackageForNonFinalVendorSoftwareProductErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CreatePackageForNonFinalVendorSoftwareProductErrorBuilder.java
index 04038fe6bc..39752b39e7 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CreatePackageForNonFinalVendorSoftwareProductErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CreatePackageForNonFinalVendorSoftwareProductErrorBuilder.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,38 +17,34 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.CREATE_PACKAGE_FOR_NON_FINAL_VSP;
+
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.versioning.dao.types.Version;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.CREATE_PACKAGE_FOR_NON_FINAL_VSP;
-
-
public class CreatePackageForNonFinalVendorSoftwareProductErrorBuilder {
- private static final String CREATE_PACKAGE_FOR_NON_FINAL_VSP_MSG =
- "Package creation for vendor software product with id %s and version %s is not allowed since "
- + "it is not final (submitted).";
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
-
- /**
- * Instantiates a new Create package for non final vendor software product error builder.
- *
- * @param vendorSoftwareProductId the vendor software product id
- * @param version the version
- */
- public CreatePackageForNonFinalVendorSoftwareProductErrorBuilder(String vendorSoftwareProductId,
- Version version) {
- builder.withId(CREATE_PACKAGE_FOR_NON_FINAL_VSP);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String
- .format(CREATE_PACKAGE_FOR_NON_FINAL_VSP_MSG, vendorSoftwareProductId, version == null ? null : version.toString()));
- }
-
- public ErrorCode build() {
- return builder.build();
- }
+ private static final String CREATE_PACKAGE_FOR_NON_FINAL_VSP_MSG =
+ "Package creation for vendor software product with id %s and version %s is not allowed since " + "it is not final (submitted).";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ /**
+ * Instantiates a new Create package for non final vendor software product error builder.
+ *
+ * @param vendorSoftwareProductId the vendor software product id
+ * @param version the version
+ */
+ public CreatePackageForNonFinalVendorSoftwareProductErrorBuilder(String vendorSoftwareProductId, Version version) {
+ builder.withId(CREATE_PACKAGE_FOR_NON_FINAL_VSP);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder
+ .withMessage(String.format(CREATE_PACKAGE_FOR_NON_FINAL_VSP_MSG, vendorSoftwareProductId, version == null ? null : version.toString()));
+ }
+
+ public ErrorCode build() {
+ return builder.build();
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeleteNicErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeleteNicErrorBuilder.java
index 6a94d81643..61ad90185f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeleteNicErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeleteNicErrorBuilder.java
@@ -13,18 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
public class DeleteNicErrorBuilder {
- private static final String DELETE_NIC_NOT_ALLOWED_MSG =
- "NIC cannot be deleted for VSPs onboarded with HEAT.";
- private DeleteNicErrorBuilder(){
+ private static final String DELETE_NIC_NOT_ALLOWED_MSG = "NIC cannot be deleted for VSPs onboarded with HEAT.";
+ private DeleteNicErrorBuilder() {
}
public static ErrorCode getDeleteNicForHeatOnboardedVspErrorBuilder() {
@@ -34,5 +32,4 @@ public class DeleteNicErrorBuilder {
builder.withMessage(String.format(DELETE_NIC_NOT_ALLOWED_MSG));
return builder.build();
}
-
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java
index ab0881268e..4869b77bc6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java
@@ -13,43 +13,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-import org.openecomp.sdc.versioning.dao.types.Version;
public class DeploymentFlavorErrorBuilder {
- private static final String CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
- "Deployment Flavor cannot be added for VSPs onboarded with HEAT.";
- private static final String FEATURE_GROUP_NOT_EXIST_FOR_VSP_MSG =
- "Invalid request, Feature Group provided does not exist for this Vsp.";
- private static final String INVALID_COMPONENT_COMPUTE_ASSOCIATION_MSG
- = "Invalid request,for valid association please provide ComponentId for Compute Flavor";
- private static final String SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED_MSG =
- "Invalid Request,Same Vfc cannot be associated more than once.";
- private static final String DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED_MSG =
- "Invalid request, Deployment Flavor with model %s already exists for Vsp with Id %s.";
- private static final String DEPLOYMENT_FLAVOUR_NAME_FORMAT_MSG = "Field does not conform to predefined criteria"
- + ": name : must match %s";
- private static final String INVALID_COMPUTE_FLAVOR_ID_MSG =
- "Invalid request, Compute Flavor provided does not exist for this VFC.";
- private static final String INVALID_COMPONENT_ID_MSG =
- "Invalid request, Component provided does not exist for this VSP.";
- private static final String INVALID_COMPONENT_COMPUTE_ASSOCIATION_ERROR_MSG="VSP cannot be " +
- "submitted with an invalid Deployment Flavor. All Deployment Flavor should have atleast a VFC included with it's required Compute needs. " +
- "Please fix the Deployment Flavor %s and re-submit the VSP.";
-
- private static final String FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR_MSG = "VSP cannot be " +
- "submitted with an invalid Deployment Flavor. All Deployment Flavor should have " +
- "FeatureGroup. Please fix the Deployment Flavor %s and re-submit the VSP.";
-
- private DeploymentFlavorErrorBuilder(){
+ private static final String CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG = "Deployment Flavor cannot be added for VSPs onboarded with HEAT.";
+ private static final String FEATURE_GROUP_NOT_EXIST_FOR_VSP_MSG = "Invalid request, Feature Group provided does not exist for this Vsp.";
+ private static final String INVALID_COMPONENT_COMPUTE_ASSOCIATION_MSG = "Invalid request,for valid association please provide ComponentId for Compute Flavor";
+ private static final String SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED_MSG = "Invalid Request,Same Vfc cannot be associated more than once.";
+ private static final String DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED_MSG = "Invalid request, Deployment Flavor with model %s already exists for Vsp with Id %s.";
+ private static final String DEPLOYMENT_FLAVOUR_NAME_FORMAT_MSG = "Field does not conform to predefined criteria" + ": name : must match %s";
+ private static final String INVALID_COMPUTE_FLAVOR_ID_MSG = "Invalid request, Compute Flavor provided does not exist for this VFC.";
+ private static final String INVALID_COMPONENT_ID_MSG = "Invalid request, Component provided does not exist for this VSP.";
+ private static final String INVALID_COMPONENT_COMPUTE_ASSOCIATION_ERROR_MSG = "VSP cannot be "
+ + "submitted with an invalid Deployment Flavor. All Deployment Flavor should have atleast a VFC included with it's required Compute needs. "
+ + "Please fix the Deployment Flavor %s and re-submit the VSP.";
+ private static final String FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR_MSG =
+ "VSP cannot be " + "submitted with an invalid Deployment Flavor. All Deployment Flavor should have "
+ + "FeatureGroup. Please fix the Deployment Flavor %s and re-submit the VSP.";
+
+ private DeploymentFlavorErrorBuilder() {
}
- public static ErrorCode getAddDeploymentNotSupportedHeatOnboardErrorBuilder(){
+ public static ErrorCode getAddDeploymentNotSupportedHeatOnboardErrorBuilder() {
ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(VendorSoftwareProductErrorCodes.CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
builder.withCategory(ErrorCategory.APPLICATION);
@@ -57,7 +46,7 @@ public class DeploymentFlavorErrorBuilder {
return builder.build();
}
- public static ErrorCode getFeatureGroupNotexistErrorBuilder(){
+ public static ErrorCode getFeatureGroupNotexistErrorBuilder() {
ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(VendorSoftwareProductErrorCodes.FEATURE_GROUP_NOT_EXIST_FOR_VSP);
builder.withCategory(ErrorCategory.APPLICATION);
@@ -65,10 +54,9 @@ public class DeploymentFlavorErrorBuilder {
return builder.build();
}
- public static ErrorCode getDuplicateVfcAssociationErrorBuilder(){
+ public static ErrorCode getDuplicateVfcAssociationErrorBuilder() {
ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(VendorSoftwareProductErrorCodes
- .SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED);
+ builder.withId(VendorSoftwareProductErrorCodes.SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED);
builder.withCategory(ErrorCategory.APPLICATION);
builder.withMessage(SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED_MSG);
return builder.build();
@@ -82,12 +70,11 @@ public class DeploymentFlavorErrorBuilder {
return builder.build();
}
- public static ErrorCode getDuplicateDeploymentFlavorModelErrorBuilder(String name,
- String vspId) {
+ public static ErrorCode getDuplicateDeploymentFlavorModelErrorBuilder(String name, String vspId) {
ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED);
builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED_MSG,name,vspId));
+ builder.withMessage(String.format(DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED_MSG, name, vspId));
return builder.build();
}
@@ -123,7 +110,7 @@ public class DeploymentFlavorErrorBuilder {
return builder.build();
}
- public static ErrorCode getDeploymentFlavorNameFormatErrorBuilder(String pattern){
+ public static ErrorCode getDeploymentFlavorNameFormatErrorBuilder(String pattern) {
ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(VendorSoftwareProductErrorCodes.DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED);
builder.withCategory(ErrorCategory.APPLICATION);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java
index 553ee920a4..4915912313 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,31 +17,27 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import org.openecomp.sdc.common.errors.ErrorCategory;
-import org.openecomp.sdc.common.errors.ErrorCode;
-
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.UPDATE_COMPUTE_NOT_ALLOWED;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
public class DuplicateComputeInComponentErrorBuilder {
- private static final String COMPUTE_HEAT_READONLY_ATTR_MSG =
- "Update of attribute %s not allowed for VSP onboarded via HEAT.";
-
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- public static ErrorCode getComputeHeatReadOnlyErrorBuilder(String name) {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(UPDATE_COMPUTE_NOT_ALLOWED);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(COMPUTE_HEAT_READONLY_ATTR_MSG, name));
- return builder.build();
- }
+ private static final String COMPUTE_HEAT_READONLY_ATTR_MSG = "Update of attribute %s not allowed for VSP onboarded via HEAT.";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ public static ErrorCode getComputeHeatReadOnlyErrorBuilder(String name) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(UPDATE_COMPUTE_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(COMPUTE_HEAT_READONLY_ATTR_MSG, name));
+ return builder.build();
+ }
- public ErrorCode build() {
- return builder.build();
- }
+ public ErrorCode build() {
+ return builder.build();
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateNicInComponentErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateNicInComponentErrorBuilder.java
index 6d5edff169..0ff6e228eb 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateNicInComponentErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateNicInComponentErrorBuilder.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
import org.openecomp.sdc.common.errors.ErrorCategory;
@@ -25,18 +24,16 @@ import org.openecomp.sdc.common.errors.ErrorCode;
public class DuplicateNicInComponentErrorBuilder {
- private static final String DUPLICATE_NIC_NAME_NOT_ALLOWED_MSG =
- "Invalid request, NIC with name %s already exist for component with ID %s.";
-
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ private static final String DUPLICATE_NIC_NAME_NOT_ALLOWED_MSG = "Invalid request, NIC with name %s already exist for component with ID %s.";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- public DuplicateNicInComponentErrorBuilder(String nicName, String componentId ){
- builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_NIC_NAME_NOT_ALLOWED);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(DUPLICATE_NIC_NAME_NOT_ALLOWED_MSG,nicName,componentId));
- }
- public ErrorCode build() {
- return builder.build();
- }
+ public DuplicateNicInComponentErrorBuilder(String nicName, String componentId) {
+ builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_NIC_NAME_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DUPLICATE_NIC_NAME_NOT_ALLOWED_MSG, nicName, componentId));
+ }
+ public ErrorCode build() {
+ return builder.build();
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/FileCreationErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/FileCreationErrorBuilder.java
index e00e145020..75388af64a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/FileCreationErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/FileCreationErrorBuilder.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,33 +17,31 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.HEAT_PACKAGE_FILE_CREATION;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.HEAT_PACKAGE_FILE_CREATION;
-
public class FileCreationErrorBuilder {
- private static final String HEAT_PKG_FILE_CREATION_ERROR_MSG =
- "Error while trying to create heat file from the package of vendor software product "
- + "with Id %s.";
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- /**
- * Instantiates a new File creation error builder.
- *
- * @param vendorSoftwareProductId the vendor software product id
- */
- public FileCreationErrorBuilder(String vendorSoftwareProductId) {
- builder.withId(HEAT_PACKAGE_FILE_CREATION);
- builder.withCategory(ErrorCategory.SYSTEM);
- builder.withMessage(String.format(HEAT_PKG_FILE_CREATION_ERROR_MSG, vendorSoftwareProductId));
- }
+ private static final String HEAT_PKG_FILE_CREATION_ERROR_MSG =
+ "Error while trying to create heat file from the package of vendor software product " + "with Id %s.";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ /**
+ * Instantiates a new File creation error builder.
+ *
+ * @param vendorSoftwareProductId the vendor software product id
+ */
+ public FileCreationErrorBuilder(String vendorSoftwareProductId) {
+ builder.withId(HEAT_PACKAGE_FILE_CREATION);
+ builder.withCategory(ErrorCategory.SYSTEM);
+ builder.withMessage(String.format(HEAT_PKG_FILE_CREATION_ERROR_MSG, vendorSoftwareProductId));
+ }
- public ErrorCode build() {
- return builder.build();
- }
+ public ErrorCode build() {
+ return builder.build();
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java
index 45bad9cad9..c5beb04a47 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java
@@ -13,90 +13,89 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DUPLICATE_IMAGE_NAME_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DUPLICATE_IMAGE_VERSION_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.IMAGE_NAME_FORMAT_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.UPDATE_IMAGE_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VFC_IMAGE_INVALID_FORMAT;
+
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.*;
-
/**
* The Image error builder.
*/
public class ImageErrorBuilder {
- private static final String VFC_IMAGE_DUPLICATE_NAME_MSG = "Invalid request, Image with name %s"
- + " already exists for component with ID %s.";
- private static final String VFC_IMAGE_NAME_FORMAT_MSG = "Field does not conform to predefined criteria"
- + ": name : must match %s";
- private static final String IMAGE_INVALID_FORMAT_MSG = "The format value doesn't meet the "
- + "expected attribute value.";
+ private static final String VFC_IMAGE_DUPLICATE_NAME_MSG = "Invalid request, Image with name %s" + " already exists for component with ID %s.";
+ private static final String VFC_IMAGE_NAME_FORMAT_MSG = "Field does not conform to predefined criteria" + ": name : must match %s";
+ private static final String IMAGE_INVALID_FORMAT_MSG = "The format value doesn't meet the " + "expected attribute value.";
+ private static final String IMAGE_HEAT_READONLY_ATTR_MSG = "Update of attribute %s not allowed " + "for VSP onboarded via HEAT.";
+ private static final String VFC_IMAGE_DUPLICATE_VERSION_MSG =
+ "Invalid request, Image with version %s" + " already exists for component with ID %s.";
- private static final String IMAGE_HEAT_READONLY_ATTR_MSG = "Update of attribute %s not allowed "
- + "for VSP onboarded via HEAT.";
- private static final String VFC_IMAGE_DUPLICATE_VERSION_MSG = "Invalid request, Image with version %s"
- + " already exists for component with ID %s.";
- private ImageErrorBuilder() {
+ private ImageErrorBuilder() {
+ }
- }
+ /**
+ * Gets duplicate image name error builder.
+ *
+ * @return the duplicate image name error builder
+ */
+ public static ErrorCode getDuplicateImageNameErrorBuilder(String imageName, String componentId) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(DUPLICATE_IMAGE_NAME_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(VFC_IMAGE_DUPLICATE_NAME_MSG, imageName, componentId));
+ return builder.build();
+ }
- /**
- * Gets duplicate image name error builder.
- *
- * @return the duplicate image name error builder
- */
- public static ErrorCode getDuplicateImageNameErrorBuilder(String imageName, String componentId) {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(DUPLICATE_IMAGE_NAME_NOT_ALLOWED);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(VFC_IMAGE_DUPLICATE_NAME_MSG, imageName, componentId ));
- return builder.build();
- }
+ /**
+ * Gets duplicate image version error builder.
+ *
+ * @return the duplicate image version error builder
+ */
+ public static ErrorCode getDuplicateImageVersionErrorBuilder(String version, String componentId) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(DUPLICATE_IMAGE_VERSION_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(VFC_IMAGE_DUPLICATE_VERSION_MSG, version, componentId));
+ return builder.build();
+ }
- /**
- * Gets duplicate image version error builder.
- *
- * @return the duplicate image version error builder
- */
- public static ErrorCode getDuplicateImageVersionErrorBuilder(String version, String componentId) {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(DUPLICATE_IMAGE_VERSION_NOT_ALLOWED);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(VFC_IMAGE_DUPLICATE_VERSION_MSG, version, componentId ));
- return builder.build();
- }
- /**
- * Gets image name format error builder.
- *
- * @return the image name format error builder
- */
- public static ErrorCode getImageNameFormatErrorBuilder(String pattern) {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(IMAGE_NAME_FORMAT_NOT_ALLOWED);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(VFC_IMAGE_NAME_FORMAT_MSG, pattern));
- return builder.build();
- }
+ /**
+ * Gets image name format error builder.
+ *
+ * @return the image name format error builder
+ */
+ public static ErrorCode getImageNameFormatErrorBuilder(String pattern) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(IMAGE_NAME_FORMAT_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(VFC_IMAGE_NAME_FORMAT_MSG, pattern));
+ return builder.build();
+ }
- /**
- * Gets invalid image format error builder.
- *
- * @return the invalid image format error builder
- */
- public static ErrorCode getInvalidImageFormatErrorBuilder() {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(VFC_IMAGE_INVALID_FORMAT);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(IMAGE_INVALID_FORMAT_MSG);
- return builder.build();
- }
+ /**
+ * Gets invalid image format error builder.
+ *
+ * @return the invalid image format error builder
+ */
+ public static ErrorCode getInvalidImageFormatErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VFC_IMAGE_INVALID_FORMAT);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(IMAGE_INVALID_FORMAT_MSG);
+ return builder.build();
+ }
- public static ErrorCode getImageHeatReadOnlyErrorBuilder(String name) {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(UPDATE_IMAGE_NOT_ALLOWED);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(IMAGE_HEAT_READONLY_ATTR_MSG, name));
- return builder.build();
- }
+ public static ErrorCode getImageHeatReadOnlyErrorBuilder(String name) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(UPDATE_IMAGE_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(IMAGE_HEAT_READONLY_ATTR_MSG, name));
+ return builder.build();
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/InformationArtifactCreationErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/InformationArtifactCreationErrorBuilder.java
index ca5b9bfcbb..e5acffe868 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/InformationArtifactCreationErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/InformationArtifactCreationErrorBuilder.java
@@ -17,31 +17,28 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import org.openecomp.sdc.common.errors.ErrorCategory;
-import org.openecomp.sdc.common.errors.ErrorCode;
-
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.HEAT_PACKAGE_FILE_CREATION;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
/**
* Created by Talio on 11/24/2016.
*/
public class InformationArtifactCreationErrorBuilder {
- private static final String INFO_ARTIFACT_FILE_CREATION_ERROR_MSG =
- "Error while trying to information artifact file for vendor software product with Id %s.";
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- public InformationArtifactCreationErrorBuilder(String vendorSoftwareProductId) {
- builder.withId(HEAT_PACKAGE_FILE_CREATION);
- builder.withCategory(ErrorCategory.SYSTEM);
- builder
- .withMessage(String.format(INFO_ARTIFACT_FILE_CREATION_ERROR_MSG, vendorSoftwareProductId));
- }
+ private static final String INFO_ARTIFACT_FILE_CREATION_ERROR_MSG = "Error while trying to information artifact file for vendor software product with Id %s.";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ public InformationArtifactCreationErrorBuilder(String vendorSoftwareProductId) {
+ builder.withId(HEAT_PACKAGE_FILE_CREATION);
+ builder.withCategory(ErrorCategory.SYSTEM);
+ builder.withMessage(String.format(INFO_ARTIFACT_FILE_CREATION_ERROR_MSG, vendorSoftwareProductId));
+ }
- public ErrorCode build() {
- return builder.build();
- }
-} \ No newline at end of file
+ public ErrorCode build() {
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java
index eed56e1a1a..0c5fb45380 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,43 +17,40 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.MONITORING_UPLOAD_INVALID;
+
import org.openecomp.sdc.common.errors.BaseErrorBuilder;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.versioning.dao.types.Version;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.MONITORING_UPLOAD_INVALID;
-
public class MonitoringUploadErrorBuilder extends BaseErrorBuilder {
- private static final String UPLOAD_INVALID_DETAILED_MSG =
- "Monitoring file uploaded for vendor software product with Id %s and version %s is invalid: %s";
+ private static final String UPLOAD_INVALID_DETAILED_MSG = "Monitoring file uploaded for vendor software product with Id %s and version %s is invalid: %s";
- /**
- * Instantiates a new Mib upload error builder.
- *
- * @param vendorSoftwareProductId the vendor software product id
- * @param version the version
- * @param error the error
- */
- public MonitoringUploadErrorBuilder(String vendorSoftwareProductId, Version version,
- String error) {
- getErrorCodeBuilder().withId(MONITORING_UPLOAD_INVALID);
- getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
- getErrorCodeBuilder().withMessage(String.format(UPLOAD_INVALID_DETAILED_MSG,
- vendorSoftwareProductId, version == null ? null : version.getId(), error));
- }
+ /**
+ * Instantiates a new Mib upload error builder.
+ *
+ * @param vendorSoftwareProductId the vendor software product id
+ * @param version the version
+ * @param error the error
+ */
+ public MonitoringUploadErrorBuilder(String vendorSoftwareProductId, Version version, String error) {
+ getErrorCodeBuilder().withId(MONITORING_UPLOAD_INVALID);
+ getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
+ getErrorCodeBuilder()
+ .withMessage(String.format(UPLOAD_INVALID_DETAILED_MSG, vendorSoftwareProductId, version == null ? null : version.getId(), error));
+ }
- /**
- * Instantiates a new Mib upload error builder.
- *
- * @param errorMessage the error message
- */
- public MonitoringUploadErrorBuilder(String errorMessage) {
- getErrorCodeBuilder().withId(MONITORING_UPLOAD_INVALID);
- getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
- getErrorCodeBuilder().withMessage(errorMessage);
- }
+ /**
+ * Instantiates a new Mib upload error builder.
+ *
+ * @param errorMessage the error message
+ */
+ public MonitoringUploadErrorBuilder(String errorMessage) {
+ getErrorCodeBuilder().withId(MONITORING_UPLOAD_INVALID);
+ getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
+ getErrorCodeBuilder().withMessage(errorMessage);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicErrorBuilder.java
index 5eb7520a38..0d63222cf5 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicErrorBuilder.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,23 +17,21 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NIC_NAME_FORMAT_NOT_ALLOWED;
+
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NIC_NAME_FORMAT_NOT_ALLOWED;
-
/**
* The NIC error builder.
*/
public class NicErrorBuilder {
- private static final String NIC_NAME_FORMAT_MSG = "Field does not conform to predefined criteria"
- + ": name : must match %s";
- private NicErrorBuilder() {
+ private static final String NIC_NAME_FORMAT_MSG = "Field does not conform to predefined criteria" + ": name : must match %s";
+ private NicErrorBuilder() {
}
/**
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java
index 5e7d8b98e3..69fabbc89f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java
@@ -13,54 +13,44 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import org.openecomp.sdc.common.errors.ErrorCategory;
-import org.openecomp.sdc.common.errors.ErrorCode;
-
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK;
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NETWORK_TYPE_UPDATE_NOT_ALLOWED;
-public class NicInternalNetworkErrorBuilder {
- private static final String NULL_NETWORKID_NOT_ALLOWED_MSG =
- "Internal Networks are currently not supported for VSP created Manually, so please fix all the NIC to be of Type External and re-submit the VSP.";
-
- private static final String NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK_MSG =
- "Invalid request, Network Description not allowed for Internal Networks";
- private static final String NETWORK_TYPE_UPDATE_NOT_ALLOWED_MSG =
- "Invalid request, Network Type Update not allowed for a Nic";
-
- private NicInternalNetworkErrorBuilder() {
-
- }
-
-
- public static ErrorCode getNicNullNetworkIdInternalNetworkIdErrorBuilder(){
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(VendorSoftwareProductErrorCodes.NULL_NETWORKID_NOT_ALLOWED);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(NULL_NETWORKID_NOT_ALLOWED_MSG);
- return builder.build();
- }
-
-
- public static ErrorCode getNetworkDescriptionInternalNetworkErrorBuilder(){
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK_MSG);
- return builder.build();
- }
-
-
- public static ErrorCode getNetworkTypeErrorBuilder(){
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(NETWORK_TYPE_UPDATE_NOT_ALLOWED);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(NETWORK_TYPE_UPDATE_NOT_ALLOWED_MSG);
- return builder.build();
- }
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+public class NicInternalNetworkErrorBuilder {
+ private static final String NULL_NETWORKID_NOT_ALLOWED_MSG = "Internal Networks are currently not supported for VSP created Manually, so please fix all the NIC to be of Type External and re-submit the VSP.";
+ private static final String NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK_MSG = "Invalid request, Network Description not allowed for Internal Networks";
+ private static final String NETWORK_TYPE_UPDATE_NOT_ALLOWED_MSG = "Invalid request, Network Type Update not allowed for a Nic";
+
+ private NicInternalNetworkErrorBuilder() {
+ }
+
+ public static ErrorCode getNicNullNetworkIdInternalNetworkIdErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.NULL_NETWORKID_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(NULL_NETWORKID_NOT_ALLOWED_MSG);
+ return builder.build();
+ }
+
+ public static ErrorCode getNetworkDescriptionInternalNetworkErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK_MSG);
+ return builder.build();
+ }
+
+ public static ErrorCode getNetworkTypeErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(NETWORK_TYPE_UPDATE_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(NETWORK_TYPE_UPDATE_NOT_ALLOWED_MSG);
+ return builder.build();
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicNetworkIdNotAllowedExternalNetworkErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicNetworkIdNotAllowedExternalNetworkErrorBuilder.java
index c40fdee62d..df7e9b30a7 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicNetworkIdNotAllowedExternalNetworkErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicNetworkIdNotAllowedExternalNetworkErrorBuilder.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,23 +17,23 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
public class NicNetworkIdNotAllowedExternalNetworkErrorBuilder {
- private static final String NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK_MSG =
- "Invalid request,NetworkId not allowed for External Networks";
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- public NicNetworkIdNotAllowedExternalNetworkErrorBuilder(){
- builder.withId(VendorSoftwareProductErrorCodes.NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK_MSG));
- }
- public ErrorCode build() {
- return builder.build();
- }
+ private static final String NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK_MSG = "Invalid request,NetworkId not allowed for External Networks";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ public NicNetworkIdNotAllowedExternalNetworkErrorBuilder() {
+ builder.withId(VendorSoftwareProductErrorCodes.NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK_MSG));
+ }
+
+ public ErrorCode build() {
+ return builder.build();
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java
index 14bfe8827d..328bd87269 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java
@@ -13,79 +13,75 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DELETE_IMAGE_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING;
+
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.*;
-
public class NotSupportedHeatOnboardMethodErrorBuilder {
- private static final String ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
- "NIC cannot be added for VSPs onboarded with HEAT.";
- private static final String ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
- "Compute flavor cannot be added for VSPs onboarded with HEAT.";
- private static final String IMAGE_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
- "Image cannot be added for VSPs onboarded with HEAT.";
- private static final String DELETE_IMAGE_NOT_ALLOWED_MSG =
- "Image cannot be deleted for VSPs onboarded with HEAT.";
- private static final String DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_MSG =
- "Deployment Flavor cannot be deleted for VSPs onboarded with HEAT.";
- private static final String EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_MSG =
- "Deployment Flavor cannot be edited for VSPs onboarded with HEAT.";
-
- private NotSupportedHeatOnboardMethodErrorBuilder() {
-
- }
+ private static final String ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG = "NIC cannot be added for VSPs onboarded with HEAT.";
+ private static final String ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG = "Compute flavor cannot be added for VSPs onboarded with HEAT.";
+ private static final String IMAGE_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG = "Image cannot be added for VSPs onboarded with HEAT.";
+ private static final String DELETE_IMAGE_NOT_ALLOWED_MSG = "Image cannot be deleted for VSPs onboarded with HEAT.";
+ private static final String DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_MSG = "Deployment Flavor cannot be deleted for VSPs onboarded with HEAT.";
+ private static final String EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_MSG = "Deployment Flavor cannot be edited for VSPs onboarded with HEAT.";
- public static ErrorCode getAddNicNotSupportedHeatOnboardMethodErrorBuilder() {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG);
- return builder.build();
- }
+ private NotSupportedHeatOnboardMethodErrorBuilder() {
+ }
- public static ErrorCode getAddComputeNotSupportedHeatOnboardMethodErrorBuilder() {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG);
- return builder.build();
- }
+ public static ErrorCode getAddNicNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG);
+ return builder.build();
+ }
- public static ErrorCode getAddImageNotSupportedHeatOnboardMethodErrorBuilder() {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(IMAGE_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG);
- return builder.build();
- }
+ public static ErrorCode getAddComputeNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG);
+ return builder.build();
+ }
- public static ErrorCode getDelImageNotSupportedHeatOnboardMethodErrorBuilder() {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(DELETE_IMAGE_NOT_ALLOWED);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(DELETE_IMAGE_NOT_ALLOWED_MSG);
- return builder.build();
- }
+ public static ErrorCode getAddImageNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(IMAGE_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG);
+ return builder.build();
+ }
- public static ErrorCode getDelDeploymentFlavorNotSupportedHeatOnboardMethodErrorBuilder() {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_MSG);
- return builder.build();
- }
+ public static ErrorCode getDelImageNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(DELETE_IMAGE_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(DELETE_IMAGE_NOT_ALLOWED_MSG);
+ return builder.build();
+ }
- public static ErrorCode getUpdateDfNotSupportedHeatOnboardMethodErrorBuilder() {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_MSG);
- return builder.build();
- }
+ public static ErrorCode getDelDeploymentFlavorNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_MSG);
+ return builder.build();
+ }
+ public static ErrorCode getUpdateDfNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_MSG);
+ return builder.build();
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java
index b30455156c..c7f130dd67 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java
@@ -13,36 +13,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_INVALID_ONBOARDING_METHOD;
+
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_INVALID_ONBOARDING_METHOD;
-
/**
* The type Onboarding method error builder.
*/
public class OnboardingMethodErrorBuilder {
- private static final String VSP_INVALID_ONBOARDING_METHOD_MSG =
- "The onboardingMethod value doesn't meet the expected attribute value.";
+ private static final String VSP_INVALID_ONBOARDING_METHOD_MSG = "The onboardingMethod value doesn't meet the expected attribute value.";
- private OnboardingMethodErrorBuilder() {
-
- }
+ private OnboardingMethodErrorBuilder() {
+ }
- /**
- * Get invalid onboarding method error builder error code.
- *
- * @return the error code
- */
- public static ErrorCode getInvalidOnboardingMethodErrorBuilder() {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(VSP_INVALID_ONBOARDING_METHOD);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(VSP_INVALID_ONBOARDING_METHOD_MSG);
- return builder.build();
- }
+ /**
+ * Get invalid onboarding method error builder error code.
+ *
+ * @return the error code
+ */
+ public static ErrorCode getInvalidOnboardingMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VSP_INVALID_ONBOARDING_METHOD);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(VSP_INVALID_ONBOARDING_METHOD_MSG);
+ return builder.build();
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OrchestrationTemplateNotFoundErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OrchestrationTemplateNotFoundErrorBuilder.java
index 84ce956911..3c6d611389 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OrchestrationTemplateNotFoundErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OrchestrationTemplateNotFoundErrorBuilder.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,32 +17,29 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ORCHESTRATION_NOT_FOUND;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ORCHESTRATION_NOT_FOUND;
-
public class OrchestrationTemplateNotFoundErrorBuilder {
- private static final String ORCHESTRATION_TEMPLATE_NOT_FOUND_MESSAGE =
- "Failed to get orchestration template for VSP with id %s";
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- /**
- * Instantiates a new Orchestration template not found error builder.
- *
- * @param vspId the vsp id
- */
- public OrchestrationTemplateNotFoundErrorBuilder(String vspId) {
- builder.withId(ORCHESTRATION_NOT_FOUND)
- .withCategory(ErrorCategory.APPLICATION)
- .withMessage(String.format(ORCHESTRATION_TEMPLATE_NOT_FOUND_MESSAGE, vspId));
- }
+ private static final String ORCHESTRATION_TEMPLATE_NOT_FOUND_MESSAGE = "Failed to get orchestration template for VSP with id %s";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ /**
+ * Instantiates a new Orchestration template not found error builder.
+ *
+ * @param vspId the vsp id
+ */
+ public OrchestrationTemplateNotFoundErrorBuilder(String vspId) {
+ builder.withId(ORCHESTRATION_NOT_FOUND).withCategory(ErrorCategory.APPLICATION)
+ .withMessage(String.format(ORCHESTRATION_TEMPLATE_NOT_FOUND_MESSAGE, vspId));
+ }
- public ErrorCode build() {
- return builder.build();
- }
+ public ErrorCode build() {
+ return builder.build();
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageInvalidErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageInvalidErrorBuilder.java
index ce9794aa3b..c0e4557f3a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageInvalidErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageInvalidErrorBuilder.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,44 +17,41 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.PACKAGE_INVALID;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.versioning.dao.types.Version;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.PACKAGE_INVALID;
-
/**
* The type Package invalid error builder.
*/
public class PackageInvalidErrorBuilder {
- private static final String PACKAGE_INVALID_MSG =
- "Package for vendor software product with Id %s and version %s is invalid "
- + "(does not contain translated data).";
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- /**
- * Instantiates a new Package invalid error builder.
- *
- * @param vendorSoftwareProductId the vendor software product id
- * @param version the version
- */
- public PackageInvalidErrorBuilder(String vendorSoftwareProductId, Version version) {
- builder.withId(PACKAGE_INVALID);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(PACKAGE_INVALID_MSG,
- vendorSoftwareProductId, version == null ? null : version.toString()));
- }
+ private static final String PACKAGE_INVALID_MSG =
+ "Package for vendor software product with Id %s and version %s is invalid " + "(does not contain translated data).";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ /**
+ * Instantiates a new Package invalid error builder.
+ *
+ * @param vendorSoftwareProductId the vendor software product id
+ * @param version the version
+ */
+ public PackageInvalidErrorBuilder(String vendorSoftwareProductId, Version version) {
+ builder.withId(PACKAGE_INVALID);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(PACKAGE_INVALID_MSG, vendorSoftwareProductId, version == null ? null : version.toString()));
+ }
- /**
- * Build error code.
- *
- * @return the error code
- */
- public ErrorCode build() {
- return builder.build();
- }
+ /**
+ * Build error code.
+ *
+ * @return the error code
+ */
+ public ErrorCode build() {
+ return builder.build();
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageNotFoundErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageNotFoundErrorBuilder.java
index 54ae9ce398..ef80e4d8db 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageNotFoundErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageNotFoundErrorBuilder.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
import org.openecomp.sdc.common.errors.ErrorCategory;
@@ -25,37 +24,35 @@ import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.versioning.dao.types.Version;
public class PackageNotFoundErrorBuilder {
- private static final String PACKAGE_VERSION_NOT_FOUND_MSG =
- "Package for vendor software product with Id %s and version %s does not exist.";
- private static final String PACKAGE_NOT_FOUND_MSG =
- "Package for vendor software product with Id %s does not exist.";
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- /**
- * Instantiates a new Package not found error builder.
- *
- * @param vendorSoftwareProductId the vendor software product id
- * @param version the version
- */
- public PackageNotFoundErrorBuilder(String vendorSoftwareProductId, Version version) {
- builder.withId(VendorSoftwareProductErrorCodes.PACKAGE_NOT_FOUND);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(PACKAGE_VERSION_NOT_FOUND_MSG,
- vendorSoftwareProductId, version == null ? null : version.toString()));
- }
+ private static final String PACKAGE_VERSION_NOT_FOUND_MSG = "Package for vendor software product with Id %s and version %s does not exist.";
+ private static final String PACKAGE_NOT_FOUND_MSG = "Package for vendor software product with Id %s does not exist.";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ /**
+ * Instantiates a new Package not found error builder.
+ *
+ * @param vendorSoftwareProductId the vendor software product id
+ * @param version the version
+ */
+ public PackageNotFoundErrorBuilder(String vendorSoftwareProductId, Version version) {
+ builder.withId(VendorSoftwareProductErrorCodes.PACKAGE_NOT_FOUND);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(PACKAGE_VERSION_NOT_FOUND_MSG, vendorSoftwareProductId, version == null ? null : version.toString()));
+ }
- /**
- * Instantiates a new Package not found error builder.
- *
- * @param vendorSoftwareProductId the vendor software product id
- */
- public PackageNotFoundErrorBuilder(String vendorSoftwareProductId) {
- builder.withId(VendorSoftwareProductErrorCodes.PACKAGE_NOT_FOUND);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(PACKAGE_NOT_FOUND_MSG, vendorSoftwareProductId));
- }
+ /**
+ * Instantiates a new Package not found error builder.
+ *
+ * @param vendorSoftwareProductId the vendor software product id
+ */
+ public PackageNotFoundErrorBuilder(String vendorSoftwareProductId) {
+ builder.withId(VendorSoftwareProductErrorCodes.PACKAGE_NOT_FOUND);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(PACKAGE_NOT_FOUND_MSG, vendorSoftwareProductId));
+ }
- public ErrorCode build() {
- return builder.build();
- }
+ public ErrorCode build() {
+ return builder.build();
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java
index fd8acd1497..73193abeb9 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,35 +17,33 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.TRANSLATION_FILE_CREATION;
+
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.versioning.dao.types.Version;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.TRANSLATION_FILE_CREATION;
-
public class TranslationFileCreationErrorBuilder {
- private static final String TRANSLATION_FILE_CREATION_ERROR_MSG =
- "Error while trying to create translation file from the package of vendor software product "
- + "with Id %s and version %s.";
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- /**
- * Instantiates a new Translation file creation error builder.
- *
- * @param vendorSoftwareProductId the vendor software product id
- * @param version the version
- */
- public TranslationFileCreationErrorBuilder(String vendorSoftwareProductId, Version version) {
- builder.withId(TRANSLATION_FILE_CREATION);
- builder.withCategory(ErrorCategory.SYSTEM);
- builder.withMessage(String
- .format(TRANSLATION_FILE_CREATION_ERROR_MSG, vendorSoftwareProductId, version.toString()));
- }
+ private static final String TRANSLATION_FILE_CREATION_ERROR_MSG =
+ "Error while trying to create translation file from the package of vendor software product " + "with Id %s and version %s.";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ /**
+ * Instantiates a new Translation file creation error builder.
+ *
+ * @param vendorSoftwareProductId the vendor software product id
+ * @param version the version
+ */
+ public TranslationFileCreationErrorBuilder(String vendorSoftwareProductId, Version version) {
+ builder.withId(TRANSLATION_FILE_CREATION);
+ builder.withCategory(ErrorCategory.SYSTEM);
+ builder.withMessage(String.format(TRANSLATION_FILE_CREATION_ERROR_MSG, vendorSoftwareProductId, version.toString()));
+ }
- public ErrorCode build() {
- return builder.build();
- }
+ public ErrorCode build() {
+ return builder.build();
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/UploadInvalidErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/UploadInvalidErrorBuilder.java
index f808d542f1..5f2abbfbcc 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/UploadInvalidErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/UploadInvalidErrorBuilder.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,60 +17,52 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
+import java.util.List;
+import java.util.Map;
import org.openecomp.sdc.common.errors.BaseErrorBuilder;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.List;
-import java.util.Map;
-
public class UploadInvalidErrorBuilder extends BaseErrorBuilder {
- private static final String UPLOAD_INVALID_DETAILED_MSG =
- "File uploaded for vendor software product with Id %s and version %s is invalid: %s";
- private static final String UPLOAD_INVALID_MSG = "Uploaded file is invalid";
- /**
- * Instantiates a new Upload invalid error builder.
- *
- * @param vendorSoftwareProductId the vendor software product id
- * @param version the version
- * @param errors the errors
- */
- public UploadInvalidErrorBuilder(String vendorSoftwareProductId, Version version,
- Map<String, List<ErrorMessage>> errors) {
- getErrorCodeBuilder().withId(VendorSoftwareProductErrorCodes.UPLOAD_INVALID);
- getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
- getErrorCodeBuilder().withMessage(String
- .format(UPLOAD_INVALID_DETAILED_MSG, vendorSoftwareProductId, version.toString(),
- toString(errors)));
- }
+ private static final String UPLOAD_INVALID_DETAILED_MSG = "File uploaded for vendor software product with Id %s and version %s is invalid: %s";
+ private static final String UPLOAD_INVALID_MSG = "Uploaded file is invalid";
- /**
- * Instantiates a new Upload invalid error builder.
- */
- public UploadInvalidErrorBuilder() {
- getErrorCodeBuilder().withId(VendorSoftwareProductErrorCodes.UPLOAD_INVALID);
- getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
- getErrorCodeBuilder().withMessage(UPLOAD_INVALID_MSG);
- }
+ /**
+ * Instantiates a new Upload invalid error builder.
+ *
+ * @param vendorSoftwareProductId the vendor software product id
+ * @param version the version
+ * @param errors the errors
+ */
+ public UploadInvalidErrorBuilder(String vendorSoftwareProductId, Version version, Map<String, List<ErrorMessage>> errors) {
+ getErrorCodeBuilder().withId(VendorSoftwareProductErrorCodes.UPLOAD_INVALID);
+ getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
+ getErrorCodeBuilder().withMessage(String.format(UPLOAD_INVALID_DETAILED_MSG, vendorSoftwareProductId, version.toString(), toString(errors)));
+ }
- private String toString(Map<String, List<ErrorMessage>> errors) {
- StringBuilder sb = new StringBuilder();
- errors.entrySet().stream()
- .forEach(entry -> singleErrorToString(sb, entry.getKey(), entry.getValue()));
- return sb.toString();
- }
+ /**
+ * Instantiates a new Upload invalid error builder.
+ */
+ public UploadInvalidErrorBuilder() {
+ getErrorCodeBuilder().withId(VendorSoftwareProductErrorCodes.UPLOAD_INVALID);
+ getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
+ getErrorCodeBuilder().withMessage(UPLOAD_INVALID_MSG);
+ }
- private void singleErrorToString(StringBuilder sb, String fileName, List<ErrorMessage> errors) {
- sb.append(System.lineSeparator());
- sb.append(fileName);
- sb.append(sb.append(": "));
- errors.stream().forEach(
- error -> sb.append(error.getMessage()).append("[").append(error.getLevel()).append("], "));
- }
+ private String toString(Map<String, List<ErrorMessage>> errors) {
+ StringBuilder sb = new StringBuilder();
+ errors.entrySet().stream().forEach(entry -> singleErrorToString(sb, entry.getKey(), entry.getValue()));
+ return sb.toString();
+ }
+ private void singleErrorToString(StringBuilder sb, String fileName, List<ErrorMessage> errors) {
+ sb.append(System.lineSeparator());
+ sb.append(fileName);
+ sb.append(sb.append(": "));
+ errors.stream().forEach(error -> sb.append(error.getMessage()).append("[").append(error.getLevel()).append("], "));
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java
index c3a2862e39..1555bd77ee 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.errors;
import org.openecomp.sdc.common.errors.ErrorCategory;
@@ -21,69 +20,59 @@ import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.versioning.dao.types.Version;
public class VendorSoftwareProductInvalidErrorBuilder {
- private static final String VSP_INVALID_MSG =
- "Vendor software product with Id %s and version %s is invalid - does not contain "
- + "service model.";
- private static final String VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG = "VSP has to have a "
- + "minimum of one Deployment Flavor defined for being able to be instantiated.Please add a "
- + "Deployment Flavor and re-submit the VSP.";
- private static final String CANDIDATE_DATA_NOT_PROCESSED_OR_ABORTED = "Uploaded network package"
- + " file %s was not processed/aborted.";
- private static final String INVALID_PROCESSED_CANDIDATE = "Uploaded network package file %s"
- + " is invalid and need to be aborted";
- private VendorSoftwareProductInvalidErrorBuilder() {
+ private static final String VSP_INVALID_MSG =
+ "Vendor software product with Id %s and version %s is invalid - does not contain " + "service model.";
+ private static final String VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG =
+ "VSP has to have a " + "minimum of one Deployment Flavor defined for being able to be instantiated.Please add a "
+ + "Deployment Flavor and re-submit the VSP.";
+ private static final String CANDIDATE_DATA_NOT_PROCESSED_OR_ABORTED = "Uploaded network package" + " file %s was not processed/aborted.";
+ private static final String INVALID_PROCESSED_CANDIDATE = "Uploaded network package file %s" + " is invalid and need to be aborted";
- }
+ private VendorSoftwareProductInvalidErrorBuilder() {
+ }
- /**
- * Instantiates a new Vendor software product invalid error builder.
- *
- * @param vendorSoftwareProductId the vendor software product id
- * @param version the version
- */
- public static ErrorCode vendorSoftwareProductMissingServiceModelErrorBuilder(String
- vendorSoftwareProductId,
- Version version) {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder
- .withMessage(String.format(VSP_INVALID_MSG, vendorSoftwareProductId, version.getId()));
- return builder.build();
- }
+ /**
+ * Instantiates a new Vendor software product invalid error builder.
+ *
+ * @param vendorSoftwareProductId the vendor software product id
+ * @param version the version
+ */
+ public static ErrorCode vendorSoftwareProductMissingServiceModelErrorBuilder(String vendorSoftwareProductId, Version version) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(VSP_INVALID_MSG, vendorSoftwareProductId, version.getId()));
+ return builder.build();
+ }
- /**
- * Instantiates a new Vendor software product invalid error builder.
- */
- public static ErrorCode vspMissingDeploymentFlavorErrorBuilder() {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder
- .withMessage(VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG);
- return builder.build();
- }
+ /**
+ * Instantiates a new Vendor software product invalid error builder.
+ */
+ public static ErrorCode vspMissingDeploymentFlavorErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG);
+ return builder.build();
+ }
- public static ErrorCode candidateDataNotProcessedOrAbortedErrorBuilder(String fileName) {
- ErrorCode.ErrorCodeBuilder builder = getErrorCodeBuilder(VendorSoftwareProductErrorCodes
- .VSP_INVALID, ErrorCategory.APPLICATION);
- builder.withMessage(String.format(CANDIDATE_DATA_NOT_PROCESSED_OR_ABORTED, fileName));
- return builder.build();
- }
+ public static ErrorCode candidateDataNotProcessedOrAbortedErrorBuilder(String fileName) {
+ ErrorCode.ErrorCodeBuilder builder = getErrorCodeBuilder(VendorSoftwareProductErrorCodes.VSP_INVALID, ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(CANDIDATE_DATA_NOT_PROCESSED_OR_ABORTED, fileName));
+ return builder.build();
+ }
- public static ErrorCode invalidProcessedCandidate(String fileName) {
- ErrorCode.ErrorCodeBuilder builder = getErrorCodeBuilder(VendorSoftwareProductErrorCodes
- .VSP_INVALID, ErrorCategory.APPLICATION);
- builder.withMessage(String.format(INVALID_PROCESSED_CANDIDATE, fileName));
- return builder.build();
- }
+ public static ErrorCode invalidProcessedCandidate(String fileName) {
+ ErrorCode.ErrorCodeBuilder builder = getErrorCodeBuilder(VendorSoftwareProductErrorCodes.VSP_INVALID, ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(INVALID_PROCESSED_CANDIDATE, fileName));
+ return builder.build();
+ }
- public static ErrorCode.ErrorCodeBuilder getErrorCodeBuilder(String errorCode, ErrorCategory
- errorCategory) {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(errorCode);
- builder.withCategory(errorCategory);
- return builder;
- }
+ public static ErrorCode.ErrorCodeBuilder getErrorCodeBuilder(String errorCode, ErrorCategory errorCategory) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(errorCode);
+ builder.withCategory(errorCategory);
+ return builder;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/exception/OnboardPackageException.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/exception/OnboardPackageException.java
index 2e88357e0b..4f487f8b50 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/exception/OnboardPackageException.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/exception/OnboardPackageException.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.exception;
public class OnboardPackageException extends Exception {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerFactoryImpl.java
index 8d8dce878e..bd7ee1ee97 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerFactoryImpl.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManager;
@@ -25,18 +24,13 @@ import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManagerFa
import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDaoFactory;
-public class ComponentDependencyModelManagerFactoryImpl extends
- ComponentDependencyModelManagerFactory {
-
- private static final ComponentDependencyModelManager INSTANCE =
- new ComponentDependencyModelManagerImpl(
- ComponentManagerFactory.getInstance().createInterface(),
- ComponentDependencyModelDaoFactory.getInstance().createInterface()
- );
+public class ComponentDependencyModelManagerFactoryImpl extends ComponentDependencyModelManagerFactory {
- @Override
- public ComponentDependencyModelManager createInterface() {
- return INSTANCE;
- }
+ private static final ComponentDependencyModelManager INSTANCE = new ComponentDependencyModelManagerImpl(
+ ComponentManagerFactory.getInstance().createInterface(), ComponentDependencyModelDaoFactory.getInstance().createInterface());
+ @Override
+ public ComponentDependencyModelManager createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java
index 596ce5010f..71b3e4b672 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java
@@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
+import java.util.Collection;
import org.apache.commons.lang3.StringUtils;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.sdc.common.errors.CoreException;
@@ -29,84 +29,68 @@ import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentDependencyModelEr
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Collection;
-
public class ComponentDependencyModelManagerImpl implements ComponentDependencyModelManager {
- private ComponentManager componentManager;
- private ComponentDependencyModelDao componentDependencyModelDao;
-
- public ComponentDependencyModelManagerImpl(
- ComponentManager componentManager, ComponentDependencyModelDao componentDependencyModelDao) {
- this.componentManager = componentManager;
- this.componentDependencyModelDao = componentDependencyModelDao;
- }
-
- @Override
- public Collection<ComponentDependencyModelEntity> list(String vspId, Version version) {
- return componentDependencyModelDao
- .list(new ComponentDependencyModelEntity(vspId, version, null));
- }
+ private ComponentManager componentManager;
+ private ComponentDependencyModelDao componentDependencyModelDao;
- @Override
- public ComponentDependencyModelEntity createComponentDependency(ComponentDependencyModelEntity
- entity, String vspId,
- Version version) {
+ public ComponentDependencyModelManagerImpl(ComponentManager componentManager, ComponentDependencyModelDao componentDependencyModelDao) {
+ this.componentManager = componentManager;
+ this.componentDependencyModelDao = componentDependencyModelDao;
+ }
- validateComponentDependency(entity);
- entity.setId(CommonMethods.nextUuId());
- componentDependencyModelDao.create(entity);
- return entity;
- }
+ @Override
+ public Collection<ComponentDependencyModelEntity> list(String vspId, Version version) {
+ return componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, version, null));
+ }
- private void validateComponentDependency(ComponentDependencyModelEntity entity) {
- if (!StringUtils.isEmpty(entity.getSourceComponentId())) {
- componentManager.validateComponentExistence(entity.getVspId(), entity.getVersion(),
- entity.getSourceComponentId());
- if (entity.getSourceComponentId().equals(entity.getTargetComponentId())) {
- ErrorCode errorCode =
- ComponentDependencyModelErrorBuilder.getSourceTargetComponentEqualErrorBuilder();
- throw new CoreException(errorCode);
- }
- } else {
- ErrorCode errorCode = ComponentDependencyModelErrorBuilder
- .getNoSourceComponentErrorBuilder();
- throw new CoreException(errorCode);
+ @Override
+ public ComponentDependencyModelEntity createComponentDependency(ComponentDependencyModelEntity entity, String vspId, Version version) {
+ validateComponentDependency(entity);
+ entity.setId(CommonMethods.nextUuId());
+ componentDependencyModelDao.create(entity);
+ return entity;
}
- if (!StringUtils.isEmpty(entity.getTargetComponentId())) {
- componentManager.validateComponentExistence(entity.getVspId(), entity.getVersion(),
- entity.getTargetComponentId());
+ private void validateComponentDependency(ComponentDependencyModelEntity entity) {
+ if (!StringUtils.isEmpty(entity.getSourceComponentId())) {
+ componentManager.validateComponentExistence(entity.getVspId(), entity.getVersion(), entity.getSourceComponentId());
+ if (entity.getSourceComponentId().equals(entity.getTargetComponentId())) {
+ ErrorCode errorCode = ComponentDependencyModelErrorBuilder.getSourceTargetComponentEqualErrorBuilder();
+ throw new CoreException(errorCode);
+ }
+ } else {
+ ErrorCode errorCode = ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder();
+ throw new CoreException(errorCode);
+ }
+ if (!StringUtils.isEmpty(entity.getTargetComponentId())) {
+ componentManager.validateComponentExistence(entity.getVspId(), entity.getVersion(), entity.getTargetComponentId());
+ }
}
- }
- @Override
- public void delete(String vspId, Version version, String dependencyId) {
- ComponentDependencyModelEntity componentDependencyEntity = getComponentDependency(vspId,
- version, dependencyId);
- if (componentDependencyEntity != null) {
- componentDependencyModelDao.delete(componentDependencyEntity);
+ @Override
+ public void delete(String vspId, Version version, String dependencyId) {
+ ComponentDependencyModelEntity componentDependencyEntity = getComponentDependency(vspId, version, dependencyId);
+ if (componentDependencyEntity != null) {
+ componentDependencyModelDao.delete(componentDependencyEntity);
+ }
}
- }
- @Override
- public void update(ComponentDependencyModelEntity entity) {
- getComponentDependency(entity.getVspId(), entity.getVersion(), entity.getId());
- validateComponentDependency(entity);
- componentDependencyModelDao.update(entity);
- }
+ @Override
+ public void update(ComponentDependencyModelEntity entity) {
+ getComponentDependency(entity.getVspId(), entity.getVersion(), entity.getId());
+ validateComponentDependency(entity);
+ componentDependencyModelDao.update(entity);
+ }
- @Override
- public ComponentDependencyModelEntity get(String vspId, Version version, String dependencyId) {
- return getComponentDependency(vspId, version, dependencyId);
- }
+ @Override
+ public ComponentDependencyModelEntity get(String vspId, Version version, String dependencyId) {
+ return getComponentDependency(vspId, version, dependencyId);
+ }
- private ComponentDependencyModelEntity getComponentDependency(String vspId, Version version,
- String dependencyId) {
- ComponentDependencyModelEntity retrieved = componentDependencyModelDao.get(
- new ComponentDependencyModelEntity(vspId, version, dependencyId));
- VersioningUtil.validateEntityExistence(retrieved, new ComponentDependencyModelEntity(
- vspId, version, dependencyId), VspDetails.ENTITY_TYPE);
- return retrieved;
- }
+ private ComponentDependencyModelEntity getComponentDependency(String vspId, Version version, String dependencyId) {
+ ComponentDependencyModelEntity retrieved = componentDependencyModelDao.get(new ComponentDependencyModelEntity(vspId, version, dependencyId));
+ VersioningUtil.validateEntityExistence(retrieved, new ComponentDependencyModelEntity(vspId, version, dependencyId), VspDetails.ENTITY_TYPE);
+ return retrieved;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerFactoryImpl.java
index 133ebdb50d..526aea13a4 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerFactoryImpl.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager;
@@ -28,16 +27,13 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
public class ComponentManagerFactoryImpl extends ComponentManagerFactory {
- private static final ComponentManager INSTANCE =
- new ComponentManagerImpl(
- ComponentDaoFactory.getInstance().createInterface(),
- CompositionEntityDataManagerFactory.getInstance().createInterface(),
- NicManagerFactory.getInstance().createInterface(),
- VendorSoftwareProductInfoDaoFactory.getInstance().createInterface()
- );
- @Override
- public ComponentManager createInterface() {
- return INSTANCE;
- }
+ private static final ComponentManager INSTANCE = new ComponentManagerImpl(ComponentDaoFactory.getInstance().createInterface(),
+ CompositionEntityDataManagerFactory.getInstance().createInterface(), NicManagerFactory.getInstance().createInterface(),
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface());
+
+ @Override
+ public ComponentManager createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
index ca8757dd11..a4527f5030 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
@@ -13,9 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
+import static org.openecomp.sdc.tosca.datatypes.ToscaNodeType.COMPUTE_TYPE_PREFIX;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.common.errors.CoreException;
@@ -42,220 +47,174 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTempl
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import static org.openecomp.sdc.tosca.datatypes.ToscaNodeType.COMPUTE_TYPE_PREFIX;
-
public class ComponentManagerImpl implements ComponentManager {
- private final ComponentDao componentDao;
- private final CompositionEntityDataManager compositionEntityDataManager;
- private final NicManager nicManager;
- private final VendorSoftwareProductInfoDao vspInfoDao;
-
- public ComponentManagerImpl(ComponentDao componentDao,
- CompositionEntityDataManager compositionEntityDataManager,
- NicManager nicManager,
- VendorSoftwareProductInfoDao vspInfoDao) {
- this.componentDao = componentDao;
- this.compositionEntityDataManager = compositionEntityDataManager;
- this.nicManager = nicManager;
- this.vspInfoDao = vspInfoDao;
- }
- @Override
- public Collection<ComponentEntity> listComponents(String vspId, Version version) {
- return componentDao.list(new ComponentEntity(vspId, version, null));
- }
-
- @Override
- public void deleteComponents(String vspId, Version version) {
- if (!vspInfoDao.isManual(vspId, version)) {
- throw new CoreException(
- new CompositionEditNotAllowedErrorBuilder(vspId, version).build());
+ private final ComponentDao componentDao;
+ private final CompositionEntityDataManager compositionEntityDataManager;
+ private final NicManager nicManager;
+ private final VendorSoftwareProductInfoDao vspInfoDao;
+
+ public ComponentManagerImpl(ComponentDao componentDao, CompositionEntityDataManager compositionEntityDataManager, NicManager nicManager,
+ VendorSoftwareProductInfoDao vspInfoDao) {
+ this.componentDao = componentDao;
+ this.compositionEntityDataManager = compositionEntityDataManager;
+ this.nicManager = nicManager;
+ this.vspInfoDao = vspInfoDao;
}
- }
-
- @Override
- public ComponentEntity createComponent(ComponentEntity component) {
- final String vfcAddNotAllowedInHeatOnboardingMsg =
- "VFCs cannot be added for VSPs onboarded with HEAT.";
- ComponentEntity createdComponent;
- if (!vspInfoDao.isManual(component.getVspId(), component.getVersion())) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder()
- .withId(VendorSoftwareProductErrorCodes.VFC_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING)
- .withMessage(vfcAddNotAllowedInHeatOnboardingMsg).build());
- } else {
- validateComponentManual(component);
- updateComponentName(component);
- createdComponent = compositionEntityDataManager.createComponent(component, true);
+ @Override
+ public Collection<ComponentEntity> listComponents(String vspId, Version version) {
+ return componentDao.list(new ComponentEntity(vspId, version, null));
}
- return createdComponent;
- }
- private void updateComponentName(ComponentEntity component) {
- ComponentData data = component.getComponentCompositionData();
- data.setName(COMPUTE_TYPE_PREFIX + data.getDisplayName());
- component.setComponentCompositionData(data);
- }
-
- private void validateComponentManual(ComponentEntity component) {
- final String vspVfcCountExceedMsg = "Creation of only one VFC per "
- + "VSP allowed.";
-
- final String vspVfcDuplicateNameMsg = "VFC with specified name "
- + "already present in given VSP.";
-
- Collection<ComponentEntity> vspComponentList =
- listComponents(component.getVspId(), component.getVersion());
- if (!vspComponentList.isEmpty()) {
- //1707 release only supports 1 VFC in VSP (manual creation)
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder()
- .withId(VendorSoftwareProductErrorCodes.VSP_VFC_COUNT_EXCEED)
- .withMessage(vspVfcCountExceedMsg).build());
+ @Override
+ public void deleteComponents(String vspId, Version version) {
+ if (!vspInfoDao.isManual(vspId, version)) {
+ throw new CoreException(new CompositionEditNotAllowedErrorBuilder(vspId, version).build());
+ }
}
- if (!isVfcNameUnique(vspComponentList,
- component.getComponentCompositionData().getDisplayName())) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder()
- .withId(VendorSoftwareProductErrorCodes.VSP_VFC_DUPLICATE_NAME)
- .withMessage(vspVfcDuplicateNameMsg).build());
- }
- }
- private boolean isVfcNameUnique(Collection<ComponentEntity> component, String displayName) {
- for (ComponentEntity comp : component) {
- if (comp.getComponentCompositionData().getDisplayName().equalsIgnoreCase(displayName)) {
- return false;
- }
+ @Override
+ public ComponentEntity createComponent(ComponentEntity component) {
+ final String vfcAddNotAllowedInHeatOnboardingMsg = "VFCs cannot be added for VSPs onboarded with HEAT.";
+ ComponentEntity createdComponent;
+ if (!vspInfoDao.isManual(component.getVspId(), component.getVersion())) {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder().withId(VendorSoftwareProductErrorCodes.VFC_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING)
+ .withMessage(vfcAddNotAllowedInHeatOnboardingMsg).build());
+ } else {
+ validateComponentManual(component);
+ updateComponentName(component);
+ createdComponent = compositionEntityDataManager.createComponent(component, true);
+ }
+ return createdComponent;
}
- return true;
- }
-
- @Override
- public CompositionEntityValidationData updateComponent(ComponentEntity component) {
- ComponentEntity retrieved =
- getValidatedComponent(component.getVspId(), component.getVersion(), component.getId());
- boolean isManual = vspInfoDao.isManual(component.getVspId(), component.getVersion());
- if (isManual) {
- validateComponentUpdateManual(retrieved);
+ private void updateComponentName(ComponentEntity component) {
+ ComponentData data = component.getComponentCompositionData();
+ data.setName(COMPUTE_TYPE_PREFIX + data.getDisplayName());
+ component.setComponentCompositionData(data);
}
- ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
- schemaInput.setManual(isManual);
- schemaInput.setComponent(retrieved.getComponentCompositionData());
-
- CompositionEntityValidationData validationData = compositionEntityDataManager
- .validateEntity(component, SchemaTemplateContext.composition, schemaInput);
- if (CollectionUtils.isEmpty(validationData.getErrors())) {
- if (isManual) {
- updateComponentName(component);
- }
- componentDao.update(component);
+ private void validateComponentManual(ComponentEntity component) {
+ final String vspVfcCountExceedMsg = "Creation of only one VFC per " + "VSP allowed.";
+ final String vspVfcDuplicateNameMsg = "VFC with specified name " + "already present in given VSP.";
+ Collection<ComponentEntity> vspComponentList = listComponents(component.getVspId(), component.getVersion());
+ if (!vspComponentList.isEmpty()) {
+ //1707 release only supports 1 VFC in VSP (manual creation)
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withId(VendorSoftwareProductErrorCodes.VSP_VFC_COUNT_EXCEED).withMessage(vspVfcCountExceedMsg)
+ .build());
+ }
+ if (!isVfcNameUnique(vspComponentList, component.getComponentCompositionData().getDisplayName())) {
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withId(VendorSoftwareProductErrorCodes.VSP_VFC_DUPLICATE_NAME).withMessage(vspVfcDuplicateNameMsg)
+ .build());
+ }
}
- return validationData;
- }
- private void validateComponentUpdateManual(ComponentEntity component) {
- Collection<ComponentEntity> vspComponentList =
- listComponents(component.getVspId(), component.getVersion());
- //VFC name should be unique within VSP
- //Removing VFC with same ID from list to avoid self compare
- for (ComponentEntity ce : vspComponentList) {
- if (ce.getId().equals(component.getId())) {
- vspComponentList.remove(ce);
- break;
- }
+ private boolean isVfcNameUnique(Collection<ComponentEntity> component, String displayName) {
+ for (ComponentEntity comp : component) {
+ if (comp.getComponentCompositionData().getDisplayName().equalsIgnoreCase(displayName)) {
+ return false;
+ }
+ }
+ return true;
}
- if (!isVfcNameUnique(vspComponentList, component.getComponentCompositionData()
- .getDisplayName())) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder()
- .withId(VendorSoftwareProductErrorCodes.VSP_VFC_DUPLICATE_NAME)
- .withMessage("VFC with specified name already present in given VSP.").build());
+ @Override
+ public CompositionEntityValidationData updateComponent(ComponentEntity component) {
+ ComponentEntity retrieved = getValidatedComponent(component.getVspId(), component.getVersion(), component.getId());
+ boolean isManual = vspInfoDao.isManual(component.getVspId(), component.getVersion());
+ if (isManual) {
+ validateComponentUpdateManual(retrieved);
+ }
+ ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
+ schemaInput.setManual(isManual);
+ schemaInput.setComponent(retrieved.getComponentCompositionData());
+ CompositionEntityValidationData validationData = compositionEntityDataManager
+ .validateEntity(component, SchemaTemplateContext.composition, schemaInput);
+ if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ if (isManual) {
+ updateComponentName(component);
+ }
+ componentDao.update(component);
+ }
+ return validationData;
}
- }
-
- @Override
- public CompositionEntityResponse<ComponentData> getComponent(String vspId, Version version,
- String componentId) {
- ComponentEntity componentEntity = getValidatedComponent(vspId, version, componentId);
- ComponentData component = componentEntity.getComponentCompositionData();
-
- ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
- schemaInput.setManual(vspInfoDao.isManual(vspId, version));
- schemaInput.setComponent(component);
-
- CompositionEntityResponse<ComponentData> response = new CompositionEntityResponse<>();
- response.setId(componentId);
- response.setData(component);
- response.setSchema(getComponentCompositionSchema(schemaInput));
- return response;
- }
- @Override
- public void deleteComponent(String vspId, Version version, String componentId) {
- if (!vspInfoDao.isManual(vspId, version)) {
- throw new CoreException(
- new CompositionEditNotAllowedErrorBuilder(vspId, version).build());
+ private void validateComponentUpdateManual(ComponentEntity component) {
+ Collection<ComponentEntity> vspComponentList = listComponents(component.getVspId(), component.getVersion());
+ //VFC name should be unique within VSP
+
+ //Removing VFC with same ID from list to avoid self compare
+ for (ComponentEntity ce : vspComponentList) {
+ if (ce.getId().equals(component.getId())) {
+ vspComponentList.remove(ce);
+ break;
+ }
+ }
+ if (!isVfcNameUnique(vspComponentList, component.getComponentCompositionData().getDisplayName())) {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder().withId(VendorSoftwareProductErrorCodes.VSP_VFC_DUPLICATE_NAME)
+ .withMessage("VFC with specified name already present in given VSP.").build());
+ }
}
- }
- @Override
- public QuestionnaireResponse getQuestionnaire(String vspId, Version version,
- String componentId) {
- QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
- ComponentEntity component = componentDao.getQuestionnaireData(vspId, version, componentId);
- VersioningUtil
- .validateEntityExistence(component, new ComponentEntity(vspId, version, componentId),
- VspDetails.ENTITY_TYPE);
+ @Override
+ public CompositionEntityResponse<ComponentData> getComponent(String vspId, Version version, String componentId) {
+ ComponentEntity componentEntity = getValidatedComponent(vspId, version, componentId);
+ ComponentData component = componentEntity.getComponentCompositionData();
+ ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
+ schemaInput.setManual(vspInfoDao.isManual(vspId, version));
+ schemaInput.setComponent(component);
+ CompositionEntityResponse<ComponentData> response = new CompositionEntityResponse<>();
+ response.setId(componentId);
+ response.setData(component);
+ response.setSchema(getComponentCompositionSchema(schemaInput));
+ return response;
+ }
- questionnaireResponse.setData(component.getQuestionnaireData());
- List<String> nicNames = nicManager.listNics(vspId, version, componentId).stream()
- .map(nic -> nic.getNicCompositionData().getName()).collect(Collectors.toList());
- questionnaireResponse.setSchema(getComponentQuestionnaireSchema(
- new ComponentQuestionnaireSchemaInput(nicNames, questionnaireResponse.getData() == null
- ? null : JsonUtil.json2Object(questionnaireResponse.getData(), Map.class),
- null, false)));
- return questionnaireResponse;
- }
+ @Override
+ public void deleteComponent(String vspId, Version version, String componentId) {
+ if (!vspInfoDao.isManual(vspId, version)) {
+ throw new CoreException(new CompositionEditNotAllowedErrorBuilder(vspId, version).build());
+ }
+ }
- @Override
- public void updateQuestionnaire(String vspId, Version version, String componentId,
- String questionnaireData) {
- validateComponentExistence(vspId, version, componentId);
+ @Override
+ public QuestionnaireResponse getQuestionnaire(String vspId, Version version, String componentId) {
+ QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
+ ComponentEntity component = componentDao.getQuestionnaireData(vspId, version, componentId);
+ VersioningUtil.validateEntityExistence(component, new ComponentEntity(vspId, version, componentId), VspDetails.ENTITY_TYPE);
+ questionnaireResponse.setData(component.getQuestionnaireData());
+ List<String> nicNames = nicManager.listNics(vspId, version, componentId).stream().map(nic -> nic.getNicCompositionData().getName())
+ .collect(Collectors.toList());
+ questionnaireResponse.setSchema(getComponentQuestionnaireSchema(new ComponentQuestionnaireSchemaInput(nicNames,
+ questionnaireResponse.getData() == null ? null : JsonUtil.json2Object(questionnaireResponse.getData(), Map.class), null, false)));
+ return questionnaireResponse;
+ }
- componentDao.updateQuestionnaireData(vspId, version, componentId, questionnaireData);
- }
+ @Override
+ public void updateQuestionnaire(String vspId, Version version, String componentId, String questionnaireData) {
+ validateComponentExistence(vspId, version, componentId);
+ componentDao.updateQuestionnaireData(vspId, version, componentId, questionnaireData);
+ }
- @Override
- public void validateComponentExistence(String vspId, Version version, String componentId) {
- getValidatedComponent(vspId, version, componentId);
- }
+ @Override
+ public void validateComponentExistence(String vspId, Version version, String componentId) {
+ getValidatedComponent(vspId, version, componentId);
+ }
- private ComponentEntity getValidatedComponent(String vspId, Version version, String componentId) {
- ComponentEntity retrieved = componentDao.get(new ComponentEntity(vspId, version, componentId));
- VersioningUtil
- .validateEntityExistence(retrieved, new ComponentEntity(vspId, version, componentId),
- VspDetails.ENTITY_TYPE);
- return retrieved;
- }
+ private ComponentEntity getValidatedComponent(String vspId, Version version, String componentId) {
+ ComponentEntity retrieved = componentDao.get(new ComponentEntity(vspId, version, componentId));
+ VersioningUtil.validateEntityExistence(retrieved, new ComponentEntity(vspId, version, componentId), VspDetails.ENTITY_TYPE);
+ return retrieved;
+ }
- protected String getComponentCompositionSchema(ComponentCompositionSchemaInput schemaInput) {
- return SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.component, schemaInput);
- }
+ protected String getComponentCompositionSchema(ComponentCompositionSchemaInput schemaInput) {
+ return SchemaGenerator.generate(SchemaTemplateContext.composition, CompositionEntityType.component, schemaInput);
+ }
- protected String getComponentQuestionnaireSchema(SchemaTemplateInput schemaInput) {
- return SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.component,
- schemaInput);
- }
+ protected String getComponentQuestionnaireSchema(SchemaTemplateInput schemaInput) {
+ return SchemaGenerator.generate(SchemaTemplateContext.questionnaire, CompositionEntityType.component, schemaInput);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerFactoryImpl.java
index 209fecc0da..ffe774ebfb 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerFactoryImpl.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,25 +17,26 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.*;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
public class CompositionEntityDataManagerFactoryImpl extends CompositionEntityDataManagerFactory {
- @Override
- public CompositionEntityDataManager createInterface() {
- // this class is stateful! it must be recreated from scratch on every use!!!
- return new CompositionEntityDataManagerImpl(
- VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
- ComponentDaoFactory.getInstance().createInterface(),
- NicDaoFactory.getInstance().createInterface(),
- NetworkDaoFactory.getInstance().createInterface(),
- ImageDaoFactory.getInstance().createInterface(),
- ComputeDaoFactory.getInstance().createInterface(),
- DeploymentFlavorDaoFactory.getInstance().createInterface());
- }
+ @Override
+ public CompositionEntityDataManager createInterface() {
+ // this class is stateful! it must be recreated from scratch on every use!!!
+ return new CompositionEntityDataManagerImpl(VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
+ ComponentDaoFactory.getInstance().createInterface(), NicDaoFactory.getInstance().createInterface(),
+ NetworkDaoFactory.getInstance().createInterface(), ImageDaoFactory.getInstance().createInterface(),
+ ComputeDaoFactory.getInstance().createInterface(), DeploymentFlavorDaoFactory.getInstance().createInterface());
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerImpl.java
index e9c75319f5..d239615cab 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerImpl.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import java.util.ArrayList;
@@ -72,535 +71,434 @@ import org.openecomp.sdc.versioning.dao.types.Version;
public class CompositionEntityDataManagerImpl implements CompositionEntityDataManager {
- private static final String COMPOSITION_ENTITY_DATA_MANAGER_ERR =
- "COMPOSITION_ENTITY_DATA_MANAGER_ERR";
- private static final String COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG =
- "Invalid input: %s may not be null";
- private static final String MISSING_OR_INVALID_QUESTIONNAIRE_MSG =
- "Data is missing/invalid for this %s. Please refill and resubmit.";
-
- private static final Logger logger =
- LoggerFactory.getLogger(CompositionEntityDataManagerImpl.class);
- private Map<CompositionEntityId, CompositionEntityData> entities = new HashMap<>();
- private Map<CompositionEntityType, String> nonDynamicSchemas =
- new EnumMap<>(CompositionEntityType.class);
- private List<CompositionEntityValidationData> roots = new ArrayList<>();
-
- private VendorSoftwareProductInfoDao vspInfoDao;
- private ComponentDao componentDao;
- private NicDao nicDao;
- private NetworkDao networkDao;
- private ImageDao imageDao;
- private ComputeDao computeDao;
- private DeploymentFlavorDao deploymentFlavorDao;
-
- public CompositionEntityDataManagerImpl(VendorSoftwareProductInfoDao vspInfoDao,
- ComponentDao componentDao,
- NicDao nicDao, NetworkDao networkDao,
- ImageDao imageDao, ComputeDao computeDao,
- DeploymentFlavorDao deploymentFlavorDao) {
- this.vspInfoDao = vspInfoDao;
- this.componentDao = componentDao;
- this.nicDao = nicDao;
- this.networkDao = networkDao;
- this.imageDao = imageDao;
- this.computeDao = computeDao;
- this.deploymentFlavorDao = deploymentFlavorDao;
- }
-
- /**
- * Validate entity composition entity validation data.
- *
- * @param entity the entity
- * @param schemaTemplateContext the schema template context
- * @param schemaTemplateInput the schema template input
- * @return the composition entity validation data
- */
- @Override
- public CompositionEntityValidationData validateEntity(CompositionEntity entity,
- SchemaTemplateContext schemaTemplateContext,
- SchemaTemplateInput schemaTemplateInput) {
- if (entity == null) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
- String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "composition entity"))
- .build());
- }
- if (schemaTemplateContext == null) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
- String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "schema template context"))
- .build());
- }
-
- CompositionEntityValidationData validationData =
- new CompositionEntityValidationData(entity.getType(), entity.getId());
- String json =
- schemaTemplateContext == SchemaTemplateContext.composition ? entity.getCompositionData()
- : entity.getQuestionnaireData();
- validationData.setErrors(JsonUtil.validate(
- json == null ? JsonUtil.object2Json(new Object()) : json,
- generateSchema(schemaTemplateContext, entity.getType(), schemaTemplateInput)));
- return validationData;
- }
-
- /**
- * Add entity.
- *
- * @param entity the entity
- * @param schemaTemplateInput the schema template input
- */
- @Override
- public void addEntity(CompositionEntity entity, SchemaTemplateInput schemaTemplateInput) {
- if (entity == null) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
- String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "composition entity"))
- .build());
- }
- entities.put(entity.getCompositionEntityId(),
- new CompositionEntityData(entity, schemaTemplateInput));
- }
-
- /**
- * Validate entities questionnaire map.
- *
- * @return the map
- */
- @Override
- public Map<CompositionEntityId, Collection<String>> validateEntitiesQuestionnaire() {
- Map<CompositionEntityId, Collection<String>> errorsByEntityId = new HashMap<>();
- entities.forEach((key, value) -> {
- Collection<String> errors = validateQuestionnaire(value);
- if (errors != null) {
- errorsByEntityId.put(key, errors);
- }
- });
- return errorsByEntityId;
- }
-
- /**
- * Build trees.
- */
- @Override
- public void buildTrees() {
- Map<CompositionEntityId, CompositionEntityValidationData> entitiesValidationData =
- new HashMap<>();
- entities.forEach((key, value) -> addValidationDataEntity(entitiesValidationData, key,
- value.entity));
- }
-
- public Collection<CompositionEntityValidationData> getTrees() {
- return roots;
- }
-
- @Override
- public void saveCompositionData(String vspId, Version version, CompositionData compositionData) {
- if (Objects.isNull(compositionData)) {
- return;
- }
-
- Map<String, String> networkIdByName = saveNetworks(vspId, version, compositionData);
- saveComponents(vspId, version, compositionData, networkIdByName);
- }
-
- @Override
- public Set<CompositionEntityValidationData> getAllErrorsByVsp(String vspId) {
- Set<CompositionEntityValidationData> entitiesWithErrors = new HashSet<>();
- for (CompositionEntityValidationData root : roots) {
- if (root.getEntityId().equals(vspId)) {
- getEntityListWithErrors(root, entitiesWithErrors);
- break;
- }
- }
-
- if (CollectionUtils.isNotEmpty(entitiesWithErrors)) {
- updateValidationCompositionEntityName(entitiesWithErrors);
- return entitiesWithErrors;
- }
-
- return new HashSet<>();
- }
-
- private void saveComponents(String vspId, Version version, CompositionData compositionData,
- Map<String, String> networkIdByName) {
- if (CollectionUtils.isNotEmpty(compositionData.getComponents())) {
- for (Component component : compositionData.getComponents()) {
- ComponentEntity componentEntity = new ComponentEntity(vspId, version, null);
- componentEntity.setComponentCompositionData(component.getData());
-
- String componentId = createComponent(componentEntity, false).getId();
-
- saveImagesByComponent(vspId, version, component, componentId);
- saveComputesFlavorByComponent(vspId, version, component, componentId);
-
- saveNicsByComponent(vspId, version, networkIdByName, component, componentId);
- }
- }
- }
-
- private void saveNicsByComponent(String vspId, Version version,
- Map<String, String> networkIdByName, Component component,
- String componentId) {
- if (CollectionUtils.isNotEmpty(component.getNics())) {
- for (Nic nic : component.getNics()) {
- if (nic.getNetworkName() != null && MapUtils.isNotEmpty(networkIdByName)) {
- nic.setNetworkId(networkIdByName.get(nic.getNetworkName()));
+ private static final String COMPOSITION_ENTITY_DATA_MANAGER_ERR = "COMPOSITION_ENTITY_DATA_MANAGER_ERR";
+ private static final String COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG = "Invalid input: %s may not be null";
+ private static final String MISSING_OR_INVALID_QUESTIONNAIRE_MSG = "Data is missing/invalid for this %s. Please refill and resubmit.";
+ private static final Logger logger = LoggerFactory.getLogger(CompositionEntityDataManagerImpl.class);
+ private Map<CompositionEntityId, CompositionEntityData> entities = new HashMap<>();
+ private Map<CompositionEntityType, String> nonDynamicSchemas = new EnumMap<>(CompositionEntityType.class);
+ private List<CompositionEntityValidationData> roots = new ArrayList<>();
+ private VendorSoftwareProductInfoDao vspInfoDao;
+ private ComponentDao componentDao;
+ private NicDao nicDao;
+ private NetworkDao networkDao;
+ private ImageDao imageDao;
+ private ComputeDao computeDao;
+ private DeploymentFlavorDao deploymentFlavorDao;
+
+ public CompositionEntityDataManagerImpl(VendorSoftwareProductInfoDao vspInfoDao, ComponentDao componentDao, NicDao nicDao, NetworkDao networkDao,
+ ImageDao imageDao, ComputeDao computeDao, DeploymentFlavorDao deploymentFlavorDao) {
+ this.vspInfoDao = vspInfoDao;
+ this.componentDao = componentDao;
+ this.nicDao = nicDao;
+ this.networkDao = networkDao;
+ this.imageDao = imageDao;
+ this.computeDao = computeDao;
+ this.deploymentFlavorDao = deploymentFlavorDao;
+ }
+
+ /**
+ * Validate entity composition entity validation data.
+ *
+ * @param entity the entity
+ * @param schemaTemplateContext the schema template context
+ * @param schemaTemplateInput the schema template input
+ * @return the composition entity validation data
+ */
+ @Override
+ public CompositionEntityValidationData validateEntity(CompositionEntity entity, SchemaTemplateContext schemaTemplateContext,
+ SchemaTemplateInput schemaTemplateInput) {
+ if (entity == null) {
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR)
+ .withMessage(String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "composition entity")).build());
+ }
+ if (schemaTemplateContext == null) {
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR)
+ .withMessage(String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "schema template context")).build());
}
- nic.setNetworkName(null);
- //For heat flow set network type to be internal by default for NIC
- nic.setNetworkType(NetworkType.Internal);
+ CompositionEntityValidationData validationData = new CompositionEntityValidationData(entity.getType(), entity.getId());
+ String json = schemaTemplateContext == SchemaTemplateContext.composition ? entity.getCompositionData() : entity.getQuestionnaireData();
+ validationData.setErrors(JsonUtil.validate(json == null ? JsonUtil.object2Json(new Object()) : json,
+ generateSchema(schemaTemplateContext, entity.getType(), schemaTemplateInput)));
+ return validationData;
+ }
- NicEntity nicEntity = new NicEntity(vspId, version, componentId, null);
- nicEntity.setNicCompositionData(nic);
- createNic(nicEntity);
- }
+ /**
+ * Add entity.
+ *
+ * @param entity the entity
+ * @param schemaTemplateInput the schema template input
+ */
+ @Override
+ public void addEntity(CompositionEntity entity, SchemaTemplateInput schemaTemplateInput) {
+ if (entity == null) {
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR)
+ .withMessage(String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "composition entity")).build());
+ }
+ entities.put(entity.getCompositionEntityId(), new CompositionEntityData(entity, schemaTemplateInput));
}
- }
- private Map<String, String> saveNetworks(String vspId, Version version,
- CompositionData compositionData) {
- Map<String, String> networkIdByName = new HashMap<>();
- if (CollectionUtils.isNotEmpty(compositionData.getNetworks())) {
- for (Network network : compositionData.getNetworks()) {
+ /**
+ * Validate entities questionnaire map.
+ *
+ * @return the map
+ */
+ @Override
+ public Map<CompositionEntityId, Collection<String>> validateEntitiesQuestionnaire() {
+ Map<CompositionEntityId, Collection<String>> errorsByEntityId = new HashMap<>();
+ entities.forEach((key, value) -> {
+ Collection<String> errors = validateQuestionnaire(value);
+ if (errors != null) {
+ errorsByEntityId.put(key, errors);
+ }
+ });
+ return errorsByEntityId;
+ }
- NetworkEntity networkEntity = new NetworkEntity(vspId, version, null);
- networkEntity.setNetworkCompositionData(network);
+ /**
+ * Build trees.
+ */
+ @Override
+ public void buildTrees() {
+ Map<CompositionEntityId, CompositionEntityValidationData> entitiesValidationData = new HashMap<>();
+ entities.forEach((key, value) -> addValidationDataEntity(entitiesValidationData, key, value.entity));
+ }
- if (network.getName() != null) {
- networkIdByName.put(network.getName(), createNetwork(networkEntity).getId());
- }
- }
+ public Collection<CompositionEntityValidationData> getTrees() {
+ return roots;
}
- return networkIdByName;
- }
- private NetworkEntity createNetwork(NetworkEntity network) {
- //network.setId(CommonMethods.nextUuId()); will be set by the dao
- networkDao.create(network);
- return network;
- }
+ @Override
+ public void saveCompositionData(String vspId, Version version, CompositionData compositionData) {
+ if (Objects.isNull(compositionData)) {
+ return;
+ }
+ Map<String, String> networkIdByName = saveNetworks(vspId, version, compositionData);
+ saveComponents(vspId, version, compositionData, networkIdByName);
+ }
- @Override
- public ComponentEntity createComponent(ComponentEntity component, boolean isManualVsp) {
- //component.setId(CommonMethods.nextUuId()); will be set by the dao
- ComponentQuestionnaireSchemaInput schemaInput = new ComponentQuestionnaireSchemaInput(null,
- null, component.getComponentCompositionData().getDisplayName(), isManualVsp);
- String questionnarieData = new JsonSchemaDataGenerator(generateSchema(SchemaTemplateContext.questionnaire,
- CompositionEntityType.component, schemaInput)).generateData();
- component.setQuestionnaireData(questionnarieData);
+ @Override
+ public Set<CompositionEntityValidationData> getAllErrorsByVsp(String vspId) {
+ Set<CompositionEntityValidationData> entitiesWithErrors = new HashSet<>();
+ for (CompositionEntityValidationData root : roots) {
+ if (root.getEntityId().equals(vspId)) {
+ getEntityListWithErrors(root, entitiesWithErrors);
+ break;
+ }
+ }
+ if (CollectionUtils.isNotEmpty(entitiesWithErrors)) {
+ updateValidationCompositionEntityName(entitiesWithErrors);
+ return entitiesWithErrors;
+ }
+ return new HashSet<>();
+ }
- componentDao.create(component);
- return component;
- }
+ private void saveComponents(String vspId, Version version, CompositionData compositionData, Map<String, String> networkIdByName) {
+ if (CollectionUtils.isNotEmpty(compositionData.getComponents())) {
+ for (Component component : compositionData.getComponents()) {
+ ComponentEntity componentEntity = new ComponentEntity(vspId, version, null);
+ componentEntity.setComponentCompositionData(component.getData());
+ String componentId = createComponent(componentEntity, false).getId();
+ saveImagesByComponent(vspId, version, component, componentId);
+ saveComputesFlavorByComponent(vspId, version, component, componentId);
+ saveNicsByComponent(vspId, version, networkIdByName, component, componentId);
+ }
+ }
+ }
- @Override
- public NicEntity createNic(NicEntity nic) {
- //nic.setId(CommonMethods.nextUuId()); will be set by the dao
- nic.setQuestionnaireData(
- new JsonSchemaDataGenerator(
- generateSchema(SchemaTemplateContext.questionnaire, CompositionEntityType.nic, null))
- .generateData());
+ private void saveNicsByComponent(String vspId, Version version, Map<String, String> networkIdByName, Component component, String componentId) {
+ if (CollectionUtils.isNotEmpty(component.getNics())) {
+ for (Nic nic : component.getNics()) {
+ if (nic.getNetworkName() != null && MapUtils.isNotEmpty(networkIdByName)) {
+ nic.setNetworkId(networkIdByName.get(nic.getNetworkName()));
+ }
+ nic.setNetworkName(null);
+ //For heat flow set network type to be internal by default for NIC
+ nic.setNetworkType(NetworkType.Internal);
+ NicEntity nicEntity = new NicEntity(vspId, version, componentId, null);
+ nicEntity.setNicCompositionData(nic);
+ createNic(nicEntity);
+ }
+ }
+ }
- nicDao.create(nic);
- return nic;
- }
+ private Map<String, String> saveNetworks(String vspId, Version version, CompositionData compositionData) {
+ Map<String, String> networkIdByName = new HashMap<>();
+ if (CollectionUtils.isNotEmpty(compositionData.getNetworks())) {
+ for (Network network : compositionData.getNetworks()) {
+ NetworkEntity networkEntity = new NetworkEntity(vspId, version, null);
+ networkEntity.setNetworkCompositionData(network);
+ if (network.getName() != null) {
+ networkIdByName.put(network.getName(), createNetwork(networkEntity).getId());
+ }
+ }
+ }
+ return networkIdByName;
+ }
+ private NetworkEntity createNetwork(NetworkEntity network) {
+ //network.setId(CommonMethods.nextUuId()); will be set by the dao
+ networkDao.create(network);
+ return network;
+ }
- public void addErrorsToTrees(Map<CompositionEntityId, Collection<String>> errors) {
- roots.forEach(root -> addErrorsToTree(root, null, errors));
- }
+ @Override
+ public ComponentEntity createComponent(ComponentEntity component, boolean isManualVsp) {
+ //component.setId(CommonMethods.nextUuId()); will be set by the dao
+ ComponentQuestionnaireSchemaInput schemaInput = new ComponentQuestionnaireSchemaInput(null, null,
+ component.getComponentCompositionData().getDisplayName(), isManualVsp);
+ String questionnarieData = new JsonSchemaDataGenerator(
+ generateSchema(SchemaTemplateContext.questionnaire, CompositionEntityType.component, schemaInput)).generateData();
+ component.setQuestionnaireData(questionnarieData);
+ componentDao.create(component);
+ return component;
+ }
- /* *
- * get a flat list of all questionnaire entities that have validation errors
- * */
- public Set<CompositionEntityValidationData> getEntityListWithErrors() {
- Set<CompositionEntityValidationData> treeAsList = new HashSet<>();
+ @Override
+ public NicEntity createNic(NicEntity nic) {
+ //nic.setId(CommonMethods.nextUuId()); will be set by the dao
+ nic.setQuestionnaireData(
+ new JsonSchemaDataGenerator(generateSchema(SchemaTemplateContext.questionnaire, CompositionEntityType.nic, null)).generateData());
+ nicDao.create(nic);
+ return nic;
+ }
- for (CompositionEntityValidationData entity : roots) {
- if (CollectionUtils.isNotEmpty(entity.getErrors())) {
- addNodeWithErrors(entity, treeAsList);
- }
- getEntityListWithErrors(entity, treeAsList);
+ public void addErrorsToTrees(Map<CompositionEntityId, Collection<String>> errors) {
+ roots.forEach(root -> addErrorsToTree(root, null, errors));
}
- updateValidationCompositionEntityName(treeAsList);
- return treeAsList;
- }
+ /* *
+ * get a flat list of all questionnaire entities that have validation errors
+ * */
+ public Set<CompositionEntityValidationData> getEntityListWithErrors() {
+ Set<CompositionEntityValidationData> treeAsList = new HashSet<>();
+ for (CompositionEntityValidationData entity : roots) {
+ if (CollectionUtils.isNotEmpty(entity.getErrors())) {
+ addNodeWithErrors(entity, treeAsList);
+ }
+ getEntityListWithErrors(entity, treeAsList);
+ }
+ updateValidationCompositionEntityName(treeAsList);
+ return treeAsList;
+ }
- private void getEntityListWithErrors(CompositionEntityValidationData entity,
- Set<CompositionEntityValidationData> compositionSet) {
- if (CollectionUtils.isNotEmpty(entity.getErrors())) {
- addNodeWithErrors(entity, compositionSet);
+ private void getEntityListWithErrors(CompositionEntityValidationData entity, Set<CompositionEntityValidationData> compositionSet) {
+ if (CollectionUtils.isNotEmpty(entity.getErrors())) {
+ addNodeWithErrors(entity, compositionSet);
+ }
+ if (CollectionUtils.isEmpty(entity.getSubEntitiesValidationData())) {
+ return;
+ }
+ for (CompositionEntityValidationData child : entity.getSubEntitiesValidationData()) {
+ getEntityListWithErrors(child, compositionSet);
+ }
}
- if (CollectionUtils.isEmpty(entity.getSubEntitiesValidationData())) {
- return;
+ private void addNodeWithErrors(CompositionEntityValidationData node, Set<CompositionEntityValidationData> entitiesWithErrors) {
+ CompositionEntityValidationData compositionNodeToAdd = new CompositionEntityValidationData(node.getEntityType(), node.getEntityId());
+ compositionNodeToAdd.setErrors(node.getErrors());
+ compositionNodeToAdd.setSubEntitiesValidationData(null);
+ entitiesWithErrors.add(compositionNodeToAdd);
}
- for (CompositionEntityValidationData child : entity.getSubEntitiesValidationData()) {
- getEntityListWithErrors(child, compositionSet);
+ public void removeNodesWithoutErrors() {
+ roots.forEach(root -> removeNodesWithoutErrors(root, null));
}
- }
+ private CompositionEntityData getCompositionEntityDataById(CompositionEntityValidationData entity) {
+ for (Map.Entry<CompositionEntityId, CompositionEntityData> entityEntry : entities.entrySet()) {
+ if (entityEntry.getKey().getId().equals(entity.getEntityId())) {
+ return entityEntry.getValue();
+ }
+ }
+ return null;
+ }
- private void addNodeWithErrors(CompositionEntityValidationData node,
- Set<CompositionEntityValidationData> entitiesWithErrors) {
- CompositionEntityValidationData compositionNodeToAdd = new CompositionEntityValidationData(node
- .getEntityType(), node.getEntityId());
- compositionNodeToAdd.setErrors(node.getErrors());
- compositionNodeToAdd.setSubEntitiesValidationData(null);
+ private void updateValidationCompositionEntityName(Set<CompositionEntityValidationData> compositionSet) {
+ for (CompositionEntityValidationData entity : compositionSet) {
+ String compositionData = getCompositionDataAsString(entity);
+ if (entity.getEntityType().equals(CompositionEntityType.vsp) || Objects.nonNull(compositionData)) {
+ entity.setEntityName(getEntityNameByEntityType(compositionData, entity));
+ }
+ }
+ }
- entitiesWithErrors.add(compositionNodeToAdd);
- }
+ private String getCompositionDataAsString(CompositionEntityValidationData entity) {
+ CompositionEntityData compositionEntityData = getCompositionEntityDataById(entity);
+ return compositionEntityData == null ? null : compositionEntityData.entity.getCompositionData();
+ }
- public void removeNodesWithoutErrors() {
- roots.forEach(root -> removeNodesWithoutErrors(root, null));
- }
+ private String getEntityNameByEntityType(String compositionData, CompositionEntityValidationData entity) {
+ switch (entity.getEntityType()) {
+ case component:
+ ComponentData component = JsonUtil.json2Object(compositionData, ComponentData.class);
+ return component.getDisplayName();
+ case nic:
+ Nic nic = JsonUtil.json2Object(compositionData, Nic.class);
+ return nic.getName();
+ case network:
+ Network network = JsonUtil.json2Object(compositionData, Network.class);
+ return network.getName();
+ case image:
+ Image image = JsonUtil.json2Object(compositionData, Image.class);
+ return image.getFileName();
+ case compute:
+ ComputeData compute = JsonUtil.json2Object(compositionData, ComputeData.class);
+ return compute.getName();
+ case vsp:
+ CompositionEntityData vspEntity = getCompositionEntityDataById(entity);
+ if (Objects.isNull(vspEntity)) {
+ return null;
+ }
+ VspQuestionnaireEntity vspQuestionnaireEntity = (VspQuestionnaireEntity) vspEntity.entity;
+ VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspQuestionnaireEntity.getId(), vspQuestionnaireEntity.getVersion()));
+ return vspDetails.getName();
+ default:
+ return null;
+ }
+ }
+ private void removeNodesWithoutErrors(CompositionEntityValidationData node, CompositionEntityValidationData parent) {
+ if (Objects.isNull(node)) {
+ return;
+ }
+ if (hasChildren(node)) {
+ Collection<CompositionEntityValidationData> subNodes = new ArrayList<>(node.getSubEntitiesValidationData());
+ subNodes.forEach(subNode -> removeNodesWithoutErrors(subNode, node));
+ node.setSubEntitiesValidationData(subNodes);
+ if (canNodeGetRemovedFromValidationDataTree(node)) {
+ removeNodeFromChildren(parent, node);
+ }
+ } else if (canNodeGetRemovedFromValidationDataTree(node)) {
+ removeNodeFromChildren(parent, node);
+ }
+ }
- private CompositionEntityData getCompositionEntityDataById(CompositionEntityValidationData
- entity) {
- for (Map.Entry<CompositionEntityId, CompositionEntityData> entityEntry : entities
- .entrySet()) {
- if (entityEntry.getKey().getId().equals(entity.getEntityId())) {
- return entityEntry.getValue();
- }
+ private void removeNodeFromChildren(CompositionEntityValidationData parent, CompositionEntityValidationData childToRemove) {
+ if (!Objects.isNull(parent)) {
+ parent.getSubEntitiesValidationData().remove(childToRemove);
+ }
}
- return null;
- }
+ private boolean hasChildren(CompositionEntityValidationData node) {
+ return !CollectionUtils.isEmpty(node.getSubEntitiesValidationData());
+ }
- private void updateValidationCompositionEntityName(Set<CompositionEntityValidationData>
- compositionSet) {
- for (CompositionEntityValidationData entity : compositionSet) {
- String compositionData = getCompositionDataAsString(entity);
- if (entity.getEntityType().equals(CompositionEntityType.vsp) ||
- Objects.nonNull(compositionData)) {
- entity.setEntityName(getEntityNameByEntityType(compositionData, entity));
- }
+ private boolean canNodeGetRemovedFromValidationDataTree(CompositionEntityValidationData node) {
+ return !hasChildren(node) && CollectionUtils.isEmpty(node.getErrors());
}
- }
- private String getCompositionDataAsString(CompositionEntityValidationData entity) {
- CompositionEntityData compositionEntityData = getCompositionEntityDataById(entity);
- return compositionEntityData == null ? null : compositionEntityData.entity.getCompositionData();
- }
+ private void addValidationDataEntity(Map<CompositionEntityId, CompositionEntityValidationData> entitiesValidationData,
+ CompositionEntityId entityId, CompositionEntity entity) {
+ if (entitiesValidationData.containsKey(entityId)) {
+ return;
+ }
+ CompositionEntityValidationData validationData = new CompositionEntityValidationData(entity.getType(), entity.getId());
+ entitiesValidationData.put(entityId, validationData);
+ CompositionEntityId parentEntityId = entityId.getParentId();
+ if (parentEntityId == null) {
+ roots.add(validationData);
+ } else {
+ CompositionEntityData parentEntity = entities.get(parentEntityId);
+ if (parentEntity == null) {
+ roots.add(validationData);
+ } else {
+ addValidationDataEntity(entitiesValidationData, parentEntityId, parentEntity.entity);
+ entitiesValidationData.get(parentEntityId).addSubEntityValidationData(validationData);
+ }
+ }
+ }
+ private void addErrorsToTree(CompositionEntityValidationData node, CompositionEntityId parentNodeId,
+ Map<CompositionEntityId, Collection<String>> errors) {
+ if (node == null) {
+ return;
+ }
+ CompositionEntityId nodeId = new CompositionEntityId(node.getEntityId(), parentNodeId);
+ node.setErrors(errors.get(nodeId));
+ if (node.getSubEntitiesValidationData() != null) {
+ node.getSubEntitiesValidationData().forEach(subNode -> addErrorsToTree(subNode, nodeId, errors));
+ }
+ }
- private String getEntityNameByEntityType(String compositionData,
- CompositionEntityValidationData entity) {
- switch (entity.getEntityType()) {
- case component:
- ComponentData component = JsonUtil.json2Object(compositionData, ComponentData.class);
- return component.getDisplayName();
+ private Collection<String> validateQuestionnaire(CompositionEntityData compositionEntityData) {
+ logger.debug(String.format("validateQuestionnaire start: " + "[entity.type]=%s, [entity.id]=%s, [entity.questionnaireString]=%s",
+ compositionEntityData.entity.getType().name(), compositionEntityData.entity.getCompositionEntityId().toString(),
+ compositionEntityData.entity.getQuestionnaireData()));
+ if (Objects.isNull(compositionEntityData.entity.getQuestionnaireData()) || !JsonUtil
+ .isValidJson(compositionEntityData.entity.getQuestionnaireData())) {
+ return Collections.singletonList(String.format(MISSING_OR_INVALID_QUESTIONNAIRE_MSG, compositionEntityData.entity.getType()));
+ }
+ return JsonUtil.validate(compositionEntityData.entity.getQuestionnaireData() == null ? JsonUtil.object2Json(new Object())
+ : compositionEntityData.entity.getQuestionnaireData(),
+ getSchema(compositionEntityData.entity.getType(), SchemaTemplateContext.questionnaire, compositionEntityData.schemaTemplateInput));
+ }
- case nic:
- Nic nic = JsonUtil.json2Object(compositionData, Nic.class);
- return nic.getName();
+ private String getSchema(CompositionEntityType compositionEntityType, SchemaTemplateContext schemaTemplateContext,
+ SchemaTemplateInput schemaTemplateInput) {
+ return schemaTemplateInput == null ? nonDynamicSchemas
+ .computeIfAbsent(compositionEntityType, k -> generateSchema(schemaTemplateContext, compositionEntityType, null))
+ : generateSchema(schemaTemplateContext, compositionEntityType, schemaTemplateInput);
+ }
- case network:
- Network network = JsonUtil.json2Object(compositionData, Network.class);
- return network.getName();
+ // make the method private
+ protected String generateSchema(SchemaTemplateContext schemaTemplateContext, CompositionEntityType compositionEntityType,
+ SchemaTemplateInput schemaTemplateInput) {
+ return SchemaGenerator.generate(schemaTemplateContext, compositionEntityType, schemaTemplateInput);
+ }
+ // todo - make SchemaGenerator non static and mock it in UT instead of mocking this method (and
- case image:
- Image image = JsonUtil.json2Object(compositionData, Image.class);
- return image.getFileName();
+ @Override
+ public DeploymentFlavorEntity createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavor) {
+ deploymentFlavor.setId(CommonMethods.nextUuId());
+ deploymentFlavorDao.create(deploymentFlavor);
+ return deploymentFlavor;
+ }
- case compute:
- ComputeData compute = JsonUtil.json2Object(compositionData, ComputeData.class);
- return compute.getName();
+ @Override
+ public ImageEntity createImage(ImageEntity image) {
+ image.setId(CommonMethods.nextUuId());
+ image.setQuestionnaireData(
+ new JsonSchemaDataGenerator(SchemaGenerator.generate(SchemaTemplateContext.questionnaire, CompositionEntityType.image, null))
+ .generateData());
+ imageDao.create(image);
+ return image;
+ }
- case vsp:
- CompositionEntityData vspEntity = getCompositionEntityDataById(entity);
- if (Objects.isNull(vspEntity)) {
- return null;
+ public void saveComputesFlavorByComponent(String vspId, Version version, Component component, String componentId) {
+ if (CollectionUtils.isNotEmpty(component.getCompute())) {
+ for (ComputeData flavor : component.getCompute()) {
+ ComputeEntity computeEntity = new ComputeEntity(vspId, version, componentId, null);
+ computeEntity.setComputeCompositionData(flavor);
+ computeEntity.setQuestionnaireData(
+ new JsonSchemaDataGenerator(SchemaGenerator.generate(SchemaTemplateContext.questionnaire, CompositionEntityType.compute, null))
+ .generateData());
+ computeDao.create(computeEntity);
+ }
}
- VspQuestionnaireEntity vspQuestionnaireEntity = (VspQuestionnaireEntity) vspEntity.entity;
- VspDetails vspDetails =
- vspInfoDao.get(new VspDetails(vspQuestionnaireEntity.getId(),
- vspQuestionnaireEntity.getVersion()));
- return vspDetails.getName();
- default:
- return null;
- }
- }
-
- private void removeNodesWithoutErrors(CompositionEntityValidationData node,
- CompositionEntityValidationData parent) {
-
- if (Objects.isNull(node)) {
- return;
}
- if (hasChildren(node)) {
- Collection<CompositionEntityValidationData> subNodes =
- new ArrayList<>(node.getSubEntitiesValidationData());
- subNodes.forEach(subNode -> removeNodesWithoutErrors(subNode, node));
- node.setSubEntitiesValidationData(subNodes);
-
- if (canNodeGetRemovedFromValidationDataTree(node)) {
- removeNodeFromChildren(parent, node);
- }
- } else if (canNodeGetRemovedFromValidationDataTree(node)) {
- removeNodeFromChildren(parent, node);
+ public void saveImagesByComponent(String vspId, Version version, Component component, String componentId) {
+ if (CollectionUtils.isNotEmpty(component.getImages())) {
+ for (Image img : component.getImages()) {
+ ImageEntity imageEntity = new ImageEntity(vspId, version, componentId, null);
+ imageEntity.setImageCompositionData(img);
+ createImage(imageEntity);
+ }
+ }
}
- }
- private void removeNodeFromChildren(CompositionEntityValidationData parent,
- CompositionEntityValidationData childToRemove) {
- if (!Objects.isNull(parent)) {
- parent.getSubEntitiesValidationData().remove(childToRemove);
- }
- }
+ private static class CompositionEntityData {
- private boolean hasChildren(CompositionEntityValidationData node) {
- return !CollectionUtils.isEmpty(node.getSubEntitiesValidationData());
- }
-
- private boolean canNodeGetRemovedFromValidationDataTree(CompositionEntityValidationData node) {
- return !hasChildren(node) && CollectionUtils.isEmpty(node.getErrors());
- }
-
-
- private void addValidationDataEntity(
- Map<CompositionEntityId, CompositionEntityValidationData> entitiesValidationData,
- CompositionEntityId entityId, CompositionEntity entity) {
- if (entitiesValidationData.containsKey(entityId)) {
- return;
- }
-
- CompositionEntityValidationData validationData =
- new CompositionEntityValidationData(entity.getType(), entity.getId());
- entitiesValidationData.put(entityId, validationData);
-
- CompositionEntityId parentEntityId = entityId.getParentId();
- if (parentEntityId == null) {
- roots.add(validationData);
- } else {
- CompositionEntityData parentEntity = entities.get(parentEntityId);
- if (parentEntity == null) {
- roots.add(validationData);
- } else {
- addValidationDataEntity(entitiesValidationData, parentEntityId, parentEntity.entity);
- entitiesValidationData.get(parentEntityId).addSubEntityValidationData(validationData);
- }
- }
- }
-
- private void addErrorsToTree(CompositionEntityValidationData node,
- CompositionEntityId parentNodeId,
- Map<CompositionEntityId, Collection<String>> errors) {
- if (node == null) {
- return;
- }
- CompositionEntityId nodeId = new CompositionEntityId(node.getEntityId(), parentNodeId);
- node.setErrors(errors.get(nodeId));
-
- if (node.getSubEntitiesValidationData() != null) {
- node.getSubEntitiesValidationData()
- .forEach(subNode -> addErrorsToTree(subNode, nodeId, errors));
- }
- }
-
- private Collection<String> validateQuestionnaire(CompositionEntityData compositionEntityData) {
- logger.debug(String.format("validateQuestionnaire start: " +
- "[entity.type]=%s, [entity.id]=%s, [entity.questionnaireString]=%s",
- compositionEntityData.entity.getType().name(),
- compositionEntityData.entity.getCompositionEntityId().toString(),
- compositionEntityData.entity.getQuestionnaireData()));
-
- if (Objects.isNull(compositionEntityData.entity.getQuestionnaireData()) ||
- !JsonUtil.isValidJson(compositionEntityData.entity.getQuestionnaireData())) {
- return Collections.singletonList(String
- .format(MISSING_OR_INVALID_QUESTIONNAIRE_MSG, compositionEntityData.entity.getType()));
- }
-
- return JsonUtil.validate(
- compositionEntityData.entity.getQuestionnaireData() == null
- ? JsonUtil.object2Json(new Object())
- : compositionEntityData.entity.getQuestionnaireData(),
- getSchema(compositionEntityData.entity.getType(), SchemaTemplateContext.questionnaire,
- compositionEntityData.schemaTemplateInput));
- }
-
- private String getSchema(CompositionEntityType compositionEntityType,
- SchemaTemplateContext schemaTemplateContext,
- SchemaTemplateInput schemaTemplateInput) {
- return schemaTemplateInput == null
- ? nonDynamicSchemas.computeIfAbsent(compositionEntityType,
- k -> generateSchema(schemaTemplateContext, compositionEntityType, null))
- : generateSchema(schemaTemplateContext, compositionEntityType, schemaTemplateInput);
- }
-
- private static class CompositionEntityData {
- private CompositionEntity entity;
- private SchemaTemplateInput schemaTemplateInput;
-
- CompositionEntityData(CompositionEntity entity, SchemaTemplateInput schemaTemplateInput) {
- this.entity = entity;
- this.schemaTemplateInput = schemaTemplateInput;
- }
-
- }
-
- // todo - make SchemaGenerator non static and mock it in UT instead of mocking this method (and
- // make the method private
- protected String generateSchema(SchemaTemplateContext schemaTemplateContext,
- CompositionEntityType compositionEntityType,
- SchemaTemplateInput schemaTemplateInput) {
- return SchemaGenerator
- .generate(schemaTemplateContext, compositionEntityType, schemaTemplateInput);
- }
-
- @Override
- public DeploymentFlavorEntity createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavor) {
- deploymentFlavor.setId(CommonMethods.nextUuId());
- deploymentFlavorDao.create(deploymentFlavor);
- return deploymentFlavor;
- }
-
- @Override
- public ImageEntity createImage(ImageEntity image) {
- image.setId(CommonMethods.nextUuId());
-
- image.setQuestionnaireData(
- new JsonSchemaDataGenerator(SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.image, null))
- .generateData());
-
- imageDao.create(image);
- return image;
- }
-
- public void saveComputesFlavorByComponent(String vspId, Version version, Component component,
- String componentId) {
- if (CollectionUtils.isNotEmpty(component.getCompute())) {
- for (ComputeData flavor : component.getCompute()) {
- ComputeEntity computeEntity = new ComputeEntity(vspId, version, componentId, null);
- computeEntity.setComputeCompositionData(flavor);
- computeEntity.setQuestionnaireData(
- new JsonSchemaDataGenerator(SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.compute,
- null)).generateData());
-
- computeDao.create(computeEntity);
- }
- }
- }
-
- public void saveImagesByComponent(String vspId, Version version, Component component, String
- componentId) {
- if (CollectionUtils.isNotEmpty(component.getImages())) {
- for (Image img : component.getImages()) {
- ImageEntity imageEntity = new ImageEntity(vspId, version, componentId, null);
- imageEntity.setImageCompositionData(img);
- createImage(imageEntity);
- }
- }
- }
+ private CompositionEntity entity;
+ private SchemaTemplateInput schemaTemplateInput;
+ CompositionEntityData(CompositionEntity entity, SchemaTemplateInput schemaTemplateInput) {
+ this.entity = entity;
+ this.schemaTemplateInput = schemaTemplateInput;
+ }
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java
index 4a1b1c1cff..c0b6fda818 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManagerFactory;
@@ -29,15 +28,12 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoF
public class ComputeManagerFactoryImpl extends ComputeManagerFactory {
- private static final ComputeManager INSTANCE =
- new ComputeManagerImpl(
- VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
- ComputeDaoFactory.getInstance().createInterface(),
- CompositionEntityDataManagerFactory.getInstance().createInterface(),
- DeploymentFlavorDaoFactory.getInstance().createInterface());
+ private static final ComputeManager INSTANCE = new ComputeManagerImpl(VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
+ ComputeDaoFactory.getInstance().createInterface(), CompositionEntityDataManagerFactory.getInstance().createInterface(),
+ DeploymentFlavorDaoFactory.getInstance().createInterface());
- @Override
- public ComputeManager createInterface() {
- return INSTANCE;
- }
+ @Override
+ public ComputeManager createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java
index 8bddeaeef4..6c319ca866 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java
@@ -13,10 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.dao.UniqueValueDaoFactory;
import org.openecomp.core.util.UniqueValueUtil;
@@ -38,279 +41,223 @@ import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGe
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.ListComputeResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.*;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComputeCompositionSchemaInput;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput;
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.*;
-
public class ComputeManagerImpl implements ComputeManager {
- private final ComputeDao computeDao;
- private final CompositionEntityDataManager compositionEntityDataManager;
- private final VendorSoftwareProductInfoDao vspInfoDao;
- private final DeploymentFlavorDao deploymentFlavorDao;
-
- public ComputeManagerImpl(VendorSoftwareProductInfoDao vspInfoDao,
- ComputeDao computeDao,
- CompositionEntityDataManager compositionEntityDataManager,
- DeploymentFlavorDao deploymentFlavorDao) {
- this.computeDao = computeDao;
- this.compositionEntityDataManager = compositionEntityDataManager;
- this.vspInfoDao = vspInfoDao;
- this.deploymentFlavorDao = deploymentFlavorDao;
- }
-
- @Override
- public ComputeEntity createCompute(ComputeEntity compute) {
- if (!vspInfoDao.isManual(compute.getVspId(), compute.getVersion())) {
- ErrorCode onboardingMethodUpdateErrorCode = NotSupportedHeatOnboardMethodErrorBuilder
- .getAddComputeNotSupportedHeatOnboardMethodErrorBuilder();
- throw new CoreException(onboardingMethodUpdateErrorCode);
- } else {
- validateUniqueName(compute.getVspId(), compute.getVersion(), compute.getComponentId(),
- compute.getComputeCompositionData().getName());
- compute.setQuestionnaireData(
- new JsonSchemaDataGenerator(getComputeQuestionnaireSchema(null)).generateData());
- computeDao.create(compute);
- createUniqueName(compute.getVspId(), compute.getVersion(), compute.getComponentId(),
- compute.getComputeCompositionData().getName());
+ private final ComputeDao computeDao;
+ private final CompositionEntityDataManager compositionEntityDataManager;
+ private final VendorSoftwareProductInfoDao vspInfoDao;
+ private final DeploymentFlavorDao deploymentFlavorDao;
+
+ public ComputeManagerImpl(VendorSoftwareProductInfoDao vspInfoDao, ComputeDao computeDao,
+ CompositionEntityDataManager compositionEntityDataManager, DeploymentFlavorDao deploymentFlavorDao) {
+ this.computeDao = computeDao;
+ this.compositionEntityDataManager = compositionEntityDataManager;
+ this.vspInfoDao = vspInfoDao;
+ this.deploymentFlavorDao = deploymentFlavorDao;
}
- return compute;
- }
+ @Override
+ public ComputeEntity createCompute(ComputeEntity compute) {
+ if (!vspInfoDao.isManual(compute.getVspId(), compute.getVersion())) {
+ ErrorCode onboardingMethodUpdateErrorCode = NotSupportedHeatOnboardMethodErrorBuilder
+ .getAddComputeNotSupportedHeatOnboardMethodErrorBuilder();
+ throw new CoreException(onboardingMethodUpdateErrorCode);
+ } else {
+ validateUniqueName(compute.getVspId(), compute.getVersion(), compute.getComponentId(), compute.getComputeCompositionData().getName());
+ compute.setQuestionnaireData(new JsonSchemaDataGenerator(getComputeQuestionnaireSchema(null)).generateData());
+ computeDao.create(compute);
+ createUniqueName(compute.getVspId(), compute.getVersion(), compute.getComponentId(), compute.getComputeCompositionData().getName());
+ }
+ return compute;
+ }
- @Override
- public Collection<ListComputeResponse> listComputes(String vspId, Version version,
- String componentId) {
- Collection<ComputeEntity> computes =
- computeDao.list(new ComputeEntity(vspId, version, componentId, null));
- return getListComputeResponse(vspId, version, computes);
- }
-
- private Collection<ListComputeResponse> getListComputeResponse(String vspId, Version version,
- Collection<ComputeEntity> computes) {
- Set<String> vspComputes = getComputeAssociatedWithDepFlavors(vspId, version);
- Collection<ListComputeResponse> computeResponse = new ArrayList<>();
- for (ComputeEntity computeEntity : computes) {
- ListComputeResponse response = new ListComputeResponse();
- response.setComputeEntity(computeEntity);
- if (vspComputes.contains(computeEntity.getId())) {
- response.setAssociatedWithDeploymentFlavor(true);
- } else {
- response.setAssociatedWithDeploymentFlavor(false);
- }
- computeResponse.add(response);
+ @Override
+ public Collection<ListComputeResponse> listComputes(String vspId, Version version, String componentId) {
+ Collection<ComputeEntity> computes = computeDao.list(new ComputeEntity(vspId, version, componentId, null));
+ return getListComputeResponse(vspId, version, computes);
}
- return computeResponse;
- }
- private Set<String> getComputeAssociatedWithDepFlavors(String vspId, Version version) {
- final Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
- Set<String> vspComputes = new HashSet<>();
- for (DeploymentFlavorEntity entity : deploymentFlavorEntities) {
- final List<ComponentComputeAssociation> componentComputeAssociations =
- entity.getDeploymentFlavorCompositionData().getComponentComputeAssociations();
- if (componentComputeAssociations != null && !componentComputeAssociations.isEmpty()) {
- for (ComponentComputeAssociation association : componentComputeAssociations) {
- vspComputes.add(association.getComputeFlavorId());
+ private Collection<ListComputeResponse> getListComputeResponse(String vspId, Version version, Collection<ComputeEntity> computes) {
+ Set<String> vspComputes = getComputeAssociatedWithDepFlavors(vspId, version);
+ Collection<ListComputeResponse> computeResponse = new ArrayList<>();
+ for (ComputeEntity computeEntity : computes) {
+ ListComputeResponse response = new ListComputeResponse();
+ response.setComputeEntity(computeEntity);
+ if (vspComputes.contains(computeEntity.getId())) {
+ response.setAssociatedWithDeploymentFlavor(true);
+ } else {
+ response.setAssociatedWithDeploymentFlavor(false);
+ }
+ computeResponse.add(response);
}
- }
+ return computeResponse;
}
- return vspComputes;
- }
- @Override
- public CompositionEntityResponse<ComputeData> getCompute(String vspId, Version version,
- String componentId,
- String computeFlavorId) {
- ComputeEntity computeEntity = getValidatedCompute(vspId, version, componentId, computeFlavorId);
- ComputeData compute = computeEntity.getComputeCompositionData();
-
- ComputeCompositionSchemaInput schemaInput = new ComputeCompositionSchemaInput();
- schemaInput.setManual(vspInfoDao.isManual(vspId, version));
- schemaInput.setCompute(compute);
-
- CompositionEntityResponse<ComputeData> response = new CompositionEntityResponse<>();
- response.setId(computeFlavorId);
- response.setData(compute);
- response.setSchema(getComputeCompositionSchema(schemaInput));
- return response;
- }
-
- private ComputeEntity getValidatedCompute(String vspId, Version version, String componentId,
- String computeFlavorId) {
- ComputeEntity retrieved = computeDao.get(new ComputeEntity(vspId, version, componentId,
- computeFlavorId));
- VersioningUtil
- .validateEntityExistence(retrieved, new ComputeEntity(vspId, version, componentId,
- computeFlavorId), VspDetails.ENTITY_TYPE);
- return retrieved;
- }
-
- @Override
- public QuestionnaireResponse getComputeQuestionnaire(String vspId, Version version, String
- componentId, String computeId) {
- QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
- ComputeEntity computeQuestionnaire =
- computeDao.getQuestionnaireData(vspId, version, componentId, computeId);
- VersioningUtil
- .validateEntityExistence(computeQuestionnaire,
- new ComputeEntity(vspId, version, componentId, computeId), VspDetails.ENTITY_TYPE);
- questionnaireResponse.setData(computeQuestionnaire.getQuestionnaireData());
- questionnaireResponse.setSchema(getComputeQuestionnaireSchema(null));
- return questionnaireResponse;
- }
-
-
- @Override
- public void updateComputeQuestionnaire(String vspId, Version version, String componentId,
- String computeId, String questionnaireData) {
- ComputeEntity retrieved = computeDao.get(new ComputeEntity(vspId, version, componentId,
- computeId));
- VersioningUtil.validateEntityExistence(retrieved, new ComputeEntity(vspId, version,
- componentId, computeId), VspDetails.ENTITY_TYPE);
-
- computeDao.updateQuestionnaireData(vspId, version, componentId, computeId, questionnaireData);
- }
+ private Set<String> getComputeAssociatedWithDepFlavors(String vspId, Version version) {
+ final Collection<DeploymentFlavorEntity> deploymentFlavorEntities = deploymentFlavorDao
+ .list(new DeploymentFlavorEntity(vspId, version, null));
+ Set<String> vspComputes = new HashSet<>();
+ for (DeploymentFlavorEntity entity : deploymentFlavorEntities) {
+ final List<ComponentComputeAssociation> componentComputeAssociations = entity.getDeploymentFlavorCompositionData()
+ .getComponentComputeAssociations();
+ if (componentComputeAssociations != null && !componentComputeAssociations.isEmpty()) {
+ for (ComponentComputeAssociation association : componentComputeAssociations) {
+ vspComputes.add(association.getComputeFlavorId());
+ }
+ }
+ }
+ return vspComputes;
+ }
- @Override
- public CompositionEntityValidationData updateCompute(ComputeEntity compute) {
- ComputeEntity retrieved =
- getComputeEntity(compute.getVspId(), compute.getVersion(), compute.getComponentId(),
- compute.getId());
+ @Override
+ public CompositionEntityResponse<ComputeData> getCompute(String vspId, Version version, String componentId, String computeFlavorId) {
+ ComputeEntity computeEntity = getValidatedCompute(vspId, version, componentId, computeFlavorId);
+ ComputeData compute = computeEntity.getComputeCompositionData();
+ ComputeCompositionSchemaInput schemaInput = new ComputeCompositionSchemaInput();
+ schemaInput.setManual(vspInfoDao.isManual(vspId, version));
+ schemaInput.setCompute(compute);
+ CompositionEntityResponse<ComputeData> response = new CompositionEntityResponse<>();
+ response.setId(computeFlavorId);
+ response.setData(compute);
+ response.setSchema(getComputeCompositionSchema(schemaInput));
+ return response;
+ }
- boolean manual = vspInfoDao.isManual(compute.getVspId(), compute.getVersion());
+ private ComputeEntity getValidatedCompute(String vspId, Version version, String componentId, String computeFlavorId) {
+ ComputeEntity retrieved = computeDao.get(new ComputeEntity(vspId, version, componentId, computeFlavorId));
+ VersioningUtil.validateEntityExistence(retrieved, new ComputeEntity(vspId, version, componentId, computeFlavorId), VspDetails.ENTITY_TYPE);
+ return retrieved;
+ }
- ComputeCompositionSchemaInput schemaInput = new ComputeCompositionSchemaInput();
- schemaInput.setManual(manual);
- schemaInput.setCompute(retrieved.getComputeCompositionData());
+ @Override
+ public QuestionnaireResponse getComputeQuestionnaire(String vspId, Version version, String componentId, String computeId) {
+ QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
+ ComputeEntity computeQuestionnaire = computeDao.getQuestionnaireData(vspId, version, componentId, computeId);
+ VersioningUtil
+ .validateEntityExistence(computeQuestionnaire, new ComputeEntity(vspId, version, componentId, computeId), VspDetails.ENTITY_TYPE);
+ questionnaireResponse.setData(computeQuestionnaire.getQuestionnaireData());
+ questionnaireResponse.setSchema(getComputeQuestionnaireSchema(null));
+ return questionnaireResponse;
+ }
- CompositionEntityValidationData validationData = compositionEntityDataManager
- .validateEntity(compute, SchemaTemplateContext.composition, schemaInput);
- if (CollectionUtils.isEmpty(validationData.getErrors())) {
- updateUniqueName(compute.getVspId(), compute.getVersion(), compute.getComponentId(),
- retrieved.getComputeCompositionData().getName(),
- compute.getComputeCompositionData().getName());
- computeDao.update(compute);
+ @Override
+ public void updateComputeQuestionnaire(String vspId, Version version, String componentId, String computeId, String questionnaireData) {
+ ComputeEntity retrieved = computeDao.get(new ComputeEntity(vspId, version, componentId, computeId));
+ VersioningUtil.validateEntityExistence(retrieved, new ComputeEntity(vspId, version, componentId, computeId), VspDetails.ENTITY_TYPE);
+ computeDao.updateQuestionnaireData(vspId, version, componentId, computeId, questionnaireData);
}
- return validationData;
- }
- private ComputeEntity getComputeEntity(String vspId, Version version, String componentId,
- String computeId) {
- ComputeEntity computeEntity =
- computeDao.get(new ComputeEntity(vspId, version, componentId, computeId));
- VersioningUtil
- .validateEntityExistence(computeEntity, new ComputeEntity(vspId, version, componentId,
- computeId), VspDetails.ENTITY_TYPE);
- return computeEntity;
- }
+ @Override
+ public CompositionEntityValidationData updateCompute(ComputeEntity compute) {
+ ComputeEntity retrieved = getComputeEntity(compute.getVspId(), compute.getVersion(), compute.getComponentId(), compute.getId());
+ boolean manual = vspInfoDao.isManual(compute.getVspId(), compute.getVersion());
+ ComputeCompositionSchemaInput schemaInput = new ComputeCompositionSchemaInput();
+ schemaInput.setManual(manual);
+ schemaInput.setCompute(retrieved.getComputeCompositionData());
+ CompositionEntityValidationData validationData = compositionEntityDataManager
+ .validateEntity(compute, SchemaTemplateContext.composition, schemaInput);
+ if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ updateUniqueName(compute.getVspId(), compute.getVersion(), compute.getComponentId(), retrieved.getComputeCompositionData().getName(),
+ compute.getComputeCompositionData().getName());
+ computeDao.update(compute);
+ }
+ return validationData;
+ }
- @Override
- public void deleteCompute(String vspId, Version version, String componentId,
- String computeFlavorId) {
- final String vspCompositionEditNotAllowedMsg =
- "Composition entities may not be created / deleted for Vendor Software Product "
- + "whose entities were uploaded";
- if (!vspInfoDao.isManual(vspId, version)) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder()
- .withId(VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED)
- .withMessage(vspCompositionEditNotAllowedMsg).build());
+ private ComputeEntity getComputeEntity(String vspId, Version version, String componentId, String computeId) {
+ ComputeEntity computeEntity = computeDao.get(new ComputeEntity(vspId, version, componentId, computeId));
+ VersioningUtil.validateEntityExistence(computeEntity, new ComputeEntity(vspId, version, componentId, computeId), VspDetails.ENTITY_TYPE);
+ return computeEntity;
}
- ComputeEntity retrieved = getValidatedCompute(vspId, version, componentId, computeFlavorId);
- if (retrieved != null) {
- deleteComputeFromDeploymentFlavors(vspId, version, computeFlavorId);
- computeDao.delete(new ComputeEntity(vspId, version, componentId, computeFlavorId));
- deleteUniqueValue(retrieved.getVspId(), retrieved.getVersion(), retrieved.getComponentId(),
- retrieved.getComputeCompositionData().getName());
+
+ @Override
+ public void deleteCompute(String vspId, Version version, String componentId, String computeFlavorId) {
+ final String vspCompositionEditNotAllowedMsg =
+ "Composition entities may not be created / deleted for Vendor Software Product " + "whose entities were uploaded";
+ if (!vspInfoDao.isManual(vspId, version)) {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder().withId(VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED)
+ .withMessage(vspCompositionEditNotAllowedMsg).build());
+ }
+ ComputeEntity retrieved = getValidatedCompute(vspId, version, componentId, computeFlavorId);
+ if (retrieved != null) {
+ deleteComputeFromDeploymentFlavors(vspId, version, computeFlavorId);
+ computeDao.delete(new ComputeEntity(vspId, version, componentId, computeFlavorId));
+ deleteUniqueValue(retrieved.getVspId(), retrieved.getVersion(), retrieved.getComponentId(),
+ retrieved.getComputeCompositionData().getName());
+ }
}
- }
- private void deleteComputeFromDeploymentFlavors(String vspId, Version version,
- String computeFlavorId) {
- Collection<DeploymentFlavorEntity> listDF =
- deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
- for (DeploymentFlavorEntity df : listDF) {
- DeploymentFlavorEntity deploymentFlavorEntity = removeComputeFromDF(df, computeFlavorId);
- if (deploymentFlavorEntity != null) {
- deploymentFlavorDao.update(deploymentFlavorEntity);
- }
+ private void deleteComputeFromDeploymentFlavors(String vspId, Version version, String computeFlavorId) {
+ Collection<DeploymentFlavorEntity> listDF = deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
+ for (DeploymentFlavorEntity df : listDF) {
+ DeploymentFlavorEntity deploymentFlavorEntity = removeComputeFromDF(df, computeFlavorId);
+ if (deploymentFlavorEntity != null) {
+ deploymentFlavorDao.update(deploymentFlavorEntity);
+ }
+ }
}
- }
- private DeploymentFlavorEntity removeComputeFromDF(DeploymentFlavorEntity df,
- String computeFlavorId) {
- DeploymentFlavor flavor = df.getDeploymentFlavorCompositionData();
- List<ComponentComputeAssociation> associations = flavor.getComponentComputeAssociations();
- if (associations != null) {
- List<ComponentComputeAssociation> updatedAssociations = new ArrayList<>();
- for (ComponentComputeAssociation ca : associations) {
- if (ca.getComputeFlavorId() != null && ca.getComputeFlavorId().equals(computeFlavorId)) {
- ComponentComputeAssociation updateCaremoveCompute = new ComponentComputeAssociation();
- updateCaremoveCompute.setComponentId(ca.getComponentId());
- updatedAssociations.add(updateCaremoveCompute);
- } else {
- updatedAssociations.add(ca);
+ private DeploymentFlavorEntity removeComputeFromDF(DeploymentFlavorEntity df, String computeFlavorId) {
+ DeploymentFlavor flavor = df.getDeploymentFlavorCompositionData();
+ List<ComponentComputeAssociation> associations = flavor.getComponentComputeAssociations();
+ if (associations != null) {
+ List<ComponentComputeAssociation> updatedAssociations = new ArrayList<>();
+ for (ComponentComputeAssociation ca : associations) {
+ if (ca.getComputeFlavorId() != null && ca.getComputeFlavorId().equals(computeFlavorId)) {
+ ComponentComputeAssociation updateCaremoveCompute = new ComponentComputeAssociation();
+ updateCaremoveCompute.setComponentId(ca.getComponentId());
+ updatedAssociations.add(updateCaremoveCompute);
+ } else {
+ updatedAssociations.add(ca);
+ }
+ }
+ flavor.setComponentComputeAssociations(updatedAssociations);
+ df.setDeploymentFlavorCompositionData(flavor);
+ return df;
}
- }
- flavor.setComponentComputeAssociations(updatedAssociations);
- df.setDeploymentFlavorCompositionData(flavor);
- return df;
+ return null;
}
- return null;
- }
- protected String getComputeCompositionSchema(SchemaTemplateInput schemaInput) {
- return SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.compute, schemaInput);
- }
+ protected String getComputeCompositionSchema(SchemaTemplateInput schemaInput) {
+ return SchemaGenerator.generate(SchemaTemplateContext.composition, CompositionEntityType.compute, schemaInput);
+ }
- protected String getComputeQuestionnaireSchema(SchemaTemplateInput schemaInput) {
- return SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.compute, schemaInput);
- }
+ protected String getComputeQuestionnaireSchema(SchemaTemplateInput schemaInput) {
+ return SchemaGenerator.generate(SchemaTemplateContext.questionnaire, CompositionEntityType.compute, schemaInput);
+ }
- protected void validateUniqueName(String vspId, Version version, String componentId,
- String name) {
- UniqueValueUtil uniqueValueUtil =
- new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface());
- uniqueValueUtil.validateUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME,
- vspId, version.getId(), componentId, name);
- }
+ protected void validateUniqueName(String vspId, Version version, String componentId, String name) {
+ UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface());
+ uniqueValueUtil.validateUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, vspId, version.getId(), componentId, name);
+ }
- protected void createUniqueName(String vspId, Version version, String componentId, String name) {
- UniqueValueUtil uniqueValueUtil =
- new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface());
- uniqueValueUtil
- .createUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, vspId,
- version.getId(), componentId, name);
- }
+ protected void createUniqueName(String vspId, Version version, String componentId, String name) {
+ UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface());
+ uniqueValueUtil.createUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, vspId, version.getId(), componentId, name);
+ }
- protected void updateUniqueName(String vspId, Version version, String componentId,
- String oldName, String newName) {
- UniqueValueUtil uniqueValueUtil =
- new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface());
- uniqueValueUtil
- .updateUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, oldName,
- newName, vspId, version.getId(), componentId);
- }
+ protected void updateUniqueName(String vspId, Version version, String componentId, String oldName, String newName) {
+ UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface());
+ uniqueValueUtil
+ .updateUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, oldName, newName, vspId, version.getId(), componentId);
+ }
- protected void deleteUniqueValue(String vspId, Version version, String componentId, String name) {
- UniqueValueUtil uniqueValueUtil =
- new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface());
- if (componentId == null) {
- uniqueValueUtil
- .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, vspId,
- version.getId(), name);
+ protected void deleteUniqueValue(String vspId, Version version, String componentId, String name) {
+ UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface());
+ if (componentId == null) {
+ uniqueValueUtil.deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, vspId, version.getId(), name);
+ }
+ uniqueValueUtil.deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, vspId, version.getId(), componentId, name);
}
- uniqueValueUtil
- .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, vspId,
- version.getId(), componentId, name);
- }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java
index dde07d43b7..fc2db3a478 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java
@@ -13,10 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-
import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManager;
import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManagerFactory;
@@ -27,16 +25,13 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoF
public class DeploymentFlavorManagerFactoryImpl extends DeploymentFlavorManagerFactory {
- private static final DeploymentFlavorManager INSTANCE = new DeploymentFlavorManagerImpl(
- VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
- DeploymentFlavorDaoFactory.getInstance().createInterface(),
- CompositionEntityDataManagerFactory.getInstance().createInterface(),
- ComputeDaoFactory.getInstance().createInterface(),
- ComponentDaoFactory.getInstance().createInterface()
- );
+ private static final DeploymentFlavorManager INSTANCE = new DeploymentFlavorManagerImpl(
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(), DeploymentFlavorDaoFactory.getInstance().createInterface(),
+ CompositionEntityDataManagerFactory.getInstance().createInterface(), ComputeDaoFactory.getInstance().createInterface(),
+ ComponentDaoFactory.getInstance().createInterface());
- @Override
- public DeploymentFlavorManager createInterface() {
- return INSTANCE;
- }
+ @Override
+ public DeploymentFlavorManager createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java
index 69d8a364db..e3f8f04bb1 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import java.util.ArrayList;
@@ -21,7 +20,6 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.openecomp.sdc.common.errors.CoreException;
@@ -49,292 +47,218 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTempl
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.*;
-
public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
- private final VendorSoftwareProductInfoDao vspInfoDao;
- private final DeploymentFlavorDao deploymentFlavorDao;
- private final CompositionEntityDataManager compositionEntityDataManager;
- private final ComputeDao computeDao;
- private final ComponentDao componentDao;
-
- public DeploymentFlavorManagerImpl(VendorSoftwareProductInfoDao vspInfoDao,
- DeploymentFlavorDao deploymentFlavorDao,
- CompositionEntityDataManager compositionEntityDataManager,
- ComputeDao computeDao, ComponentDao componentDao) {
- this.vspInfoDao = vspInfoDao;
- this.deploymentFlavorDao = deploymentFlavorDao;
- this.compositionEntityDataManager = compositionEntityDataManager;
- this.computeDao = computeDao;
- this.componentDao = componentDao;
-
- }
- @Override
- public Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version) {
- return deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
- }
+ private final VendorSoftwareProductInfoDao vspInfoDao;
+ private final DeploymentFlavorDao deploymentFlavorDao;
+ private final CompositionEntityDataManager compositionEntityDataManager;
+ private final ComputeDao computeDao;
+ private final ComponentDao componentDao;
+
+ public DeploymentFlavorManagerImpl(VendorSoftwareProductInfoDao vspInfoDao, DeploymentFlavorDao deploymentFlavorDao,
+ CompositionEntityDataManager compositionEntityDataManager, ComputeDao computeDao, ComponentDao componentDao) {
+ this.vspInfoDao = vspInfoDao;
+ this.deploymentFlavorDao = deploymentFlavorDao;
+ this.compositionEntityDataManager = compositionEntityDataManager;
+ this.computeDao = computeDao;
+ this.componentDao = componentDao;
+ }
- @Override
- public DeploymentFlavorEntity createDeploymentFlavor(
- DeploymentFlavorEntity deploymentFlavorEntity) {
- DeploymentFlavorEntity createDeploymentFlavor;
- if (!vspInfoDao.isManual(deploymentFlavorEntity.getVspId(), deploymentFlavorEntity.getVersion())) {
- ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
- .getAddDeploymentNotSupportedHeatOnboardErrorBuilder();
- throw new CoreException(deploymentFlavorErrorBuilder);
- } else {
- validateDeploymentFlavor(deploymentFlavorEntity, deploymentFlavorEntity.getVersion());
- createDeploymentFlavor =
- compositionEntityDataManager.createDeploymentFlavor(deploymentFlavorEntity);
+ @Override
+ public Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version) {
+ return deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
}
- return createDeploymentFlavor;
- }
- private void validateDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity,
- Version version) {
- //Validation for unique model.
- Collection<DeploymentFlavorEntity> listDeploymentFlavors =
- listDeploymentFlavors(deploymentFlavorEntity.getVspId(),
- version);
- isDeploymentFlavorModelDuplicate(deploymentFlavorEntity, listDeploymentFlavors);
+ @Override
+ public DeploymentFlavorEntity createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity) {
+ DeploymentFlavorEntity createDeploymentFlavor;
+ if (!vspInfoDao.isManual(deploymentFlavorEntity.getVspId(), deploymentFlavorEntity.getVersion())) {
+ ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder.getAddDeploymentNotSupportedHeatOnboardErrorBuilder();
+ throw new CoreException(deploymentFlavorErrorBuilder);
+ } else {
+ validateDeploymentFlavor(deploymentFlavorEntity, deploymentFlavorEntity.getVersion());
+ createDeploymentFlavor = compositionEntityDataManager.createDeploymentFlavor(deploymentFlavorEntity);
+ }
+ return createDeploymentFlavor;
+ }
- List<String> featureGroups =
- getFeatureGroupListForVsp(deploymentFlavorEntity.getVspId(), version);
- String featureGroup = deploymentFlavorEntity.getDeploymentFlavorCompositionData()
- .getFeatureGroupId();
- if (featureGroup != null && featureGroup.trim().length() > 0
- && (isEmpty(featureGroups) || (!(validFeatureGroup(featureGroups, featureGroup))))) {
- ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
- .getFeatureGroupNotexistErrorBuilder();
- throw new CoreException(deploymentFlavorErrorBuilder);
+ private void validateDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity, Version version) {
+ //Validation for unique model.
+ Collection<DeploymentFlavorEntity> listDeploymentFlavors = listDeploymentFlavors(deploymentFlavorEntity.getVspId(), version);
+ isDeploymentFlavorModelDuplicate(deploymentFlavorEntity, listDeploymentFlavors);
+ List<String> featureGroups = getFeatureGroupListForVsp(deploymentFlavorEntity.getVspId(), version);
+ String featureGroup = deploymentFlavorEntity.getDeploymentFlavorCompositionData().getFeatureGroupId();
+ if (featureGroup != null && featureGroup.trim().length() > 0 && (isEmpty(featureGroups) || (!(validFeatureGroup(featureGroups,
+ featureGroup))))) {
+ ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder.getFeatureGroupNotexistErrorBuilder();
+ throw new CoreException(deploymentFlavorErrorBuilder);
+ }
+ validateComponentComputeAssociation(deploymentFlavorEntity, version);
}
- validateComponentComputeAssociation(deploymentFlavorEntity, version);
- }
- private void isDeploymentFlavorModelDuplicate(DeploymentFlavorEntity deploymentFlavorEntity,
- Collection<DeploymentFlavorEntity> listDeploymentFlavors) {
- listDeploymentFlavors.forEach(deploymentFlavor -> {
- if (deploymentFlavorEntity.getDeploymentFlavorCompositionData().getModel().equalsIgnoreCase(
- deploymentFlavor.getDeploymentFlavorCompositionData().getModel())) {
- ErrorCode deploymentFlavorModelErrorBuilder = DeploymentFlavorErrorBuilder
- .getDuplicateDeploymentFlavorModelErrorBuilder(
- deploymentFlavorEntity.getDeploymentFlavorCompositionData().getModel(),
- deploymentFlavorEntity.getVspId());
- throw new CoreException(deploymentFlavorModelErrorBuilder);
- }
- });
- }
+ private void isDeploymentFlavorModelDuplicate(DeploymentFlavorEntity deploymentFlavorEntity,
+ Collection<DeploymentFlavorEntity> listDeploymentFlavors) {
+ listDeploymentFlavors.forEach(deploymentFlavor -> {
+ if (deploymentFlavorEntity.getDeploymentFlavorCompositionData().getModel()
+ .equalsIgnoreCase(deploymentFlavor.getDeploymentFlavorCompositionData().getModel())) {
+ ErrorCode deploymentFlavorModelErrorBuilder = DeploymentFlavorErrorBuilder
+ .getDuplicateDeploymentFlavorModelErrorBuilder(deploymentFlavorEntity.getDeploymentFlavorCompositionData().getModel(),
+ deploymentFlavorEntity.getVspId());
+ throw new CoreException(deploymentFlavorModelErrorBuilder);
+ }
+ });
+ }
- private List<String> getFeatureGroupListForVsp(String vspId, Version version) {
- final VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
- return vspDetails.getFeatureGroups();
- }
+ private List<String> getFeatureGroupListForVsp(String vspId, Version version) {
+ final VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
+ return vspDetails.getFeatureGroups();
+ }
- private boolean isEmpty(Collection coll) {
- return coll == null || coll.isEmpty();
- }
+ private boolean isEmpty(Collection coll) {
+ return coll == null || coll.isEmpty();
+ }
- private boolean validFeatureGroup(List<String> featureGroups, String featureGroupId) {
- Iterator<String> iterator = featureGroups.iterator();
- boolean valid = false;
- while (iterator.hasNext()) {
- String fgId = iterator.next().trim();
- if (fgId.equals(featureGroupId)) {
- valid = true;
- break;
- } else {
- valid = false;
- }
+ private boolean validFeatureGroup(List<String> featureGroups, String featureGroupId) {
+ Iterator<String> iterator = featureGroups.iterator();
+ boolean valid = false;
+ while (iterator.hasNext()) {
+ String fgId = iterator.next().trim();
+ if (fgId.equals(featureGroupId)) {
+ valid = true;
+ break;
+ } else {
+ valid = false;
+ }
+ }
+ return valid;
}
- return valid;
- }
- private void validateComponentComputeAssociation(DeploymentFlavorEntity deploymentFlavorEntity,
- Version version) {
- List<ComponentComputeAssociation> componentComputeAssociationList =
- deploymentFlavorEntity.getDeploymentFlavorCompositionData().getComponentComputeAssociations();
+ private void validateComponentComputeAssociation(DeploymentFlavorEntity deploymentFlavorEntity, Version version) {
+ List<ComponentComputeAssociation> componentComputeAssociationList = deploymentFlavorEntity.getDeploymentFlavorCompositionData()
+ .getComponentComputeAssociations();
List<String> vfcList = new ArrayList<>();
if (!isEmpty(componentComputeAssociationList)) {
componentComputeAssociationList.forEach(
- componentComputeAssociation -> validateComponentComputeAssocoationList(deploymentFlavorEntity,
- version,
- vfcList, componentComputeAssociation));
+ componentComputeAssociation -> validateComponentComputeAssocoationList(deploymentFlavorEntity, version, vfcList,
+ componentComputeAssociation));
Map<String, Integer> frequencyMapping = CollectionUtils.getCardinalityMap(vfcList);
-
for (Integer vfcCount : frequencyMapping.values()) {
if (vfcCount != 1) {
- ErrorCode duplicateVfcAssociationErrorBuilder =
- DeploymentFlavorErrorBuilder.getDuplicateVfcAssociationErrorBuilder();
+ ErrorCode duplicateVfcAssociationErrorBuilder = DeploymentFlavorErrorBuilder.getDuplicateVfcAssociationErrorBuilder();
throw new CoreException(duplicateVfcAssociationErrorBuilder);
}
}
}
}
- private void validateComponentComputeAssocoationList(
- DeploymentFlavorEntity deploymentFlavorEntity,
- Version version,
- List<String> vfcList,
- ComponentComputeAssociation componentComputeAssociation) {
- if ((componentComputeAssociation.getComponentId() == null || componentComputeAssociation
- .getComponentId().trim().length() == 0)
- && (componentComputeAssociation
- .getComputeFlavorId() != null && componentComputeAssociation
- .getComputeFlavorId().trim().length() > 0)) {
- ErrorCode invalidAssociationErrorBuilder = DeploymentFlavorErrorBuilder
- .getInvalidAssociationErrorBuilder();
+ private void validateComponentComputeAssocoationList(DeploymentFlavorEntity deploymentFlavorEntity, Version version, List<String> vfcList,
+ ComponentComputeAssociation componentComputeAssociation) {
+ if ((componentComputeAssociation.getComponentId() == null || componentComputeAssociation.getComponentId().trim().length() == 0) && (
+ componentComputeAssociation.getComputeFlavorId() != null && componentComputeAssociation.getComputeFlavorId().trim().length() > 0)) {
+ ErrorCode invalidAssociationErrorBuilder = DeploymentFlavorErrorBuilder.getInvalidAssociationErrorBuilder();
throw new CoreException(invalidAssociationErrorBuilder);
- } else if (componentComputeAssociation.getComponentId() != null
- && componentComputeAssociation.getComponentId().trim().length() > 0) {
- validateComponentAssociation(deploymentFlavorEntity,
- version, componentComputeAssociation);
-
- validateComponentComputeAssociationFlavour(deploymentFlavorEntity,
- version, componentComputeAssociation);
+ } else if (componentComputeAssociation.getComponentId() != null && componentComputeAssociation.getComponentId().trim().length() > 0) {
+ validateComponentAssociation(deploymentFlavorEntity, version, componentComputeAssociation);
+ validateComponentComputeAssociationFlavour(deploymentFlavorEntity, version, componentComputeAssociation);
vfcList.add(componentComputeAssociation.getComponentId());
}
}
private void validateComponentAssociation(DeploymentFlavorEntity deploymentFlavorEntity, Version version,
ComponentComputeAssociation componentComputeAssociation) {
-
if (StringUtils.isNotBlank(componentComputeAssociation.getComponentId())) {
- ComponentEntity componentEntity =
- componentDao.get(new ComponentEntity(deploymentFlavorEntity.getVspId(), version,
- componentComputeAssociation.getComponentId()));
+ ComponentEntity componentEntity = componentDao
+ .get(new ComponentEntity(deploymentFlavorEntity.getVspId(), version, componentComputeAssociation.getComponentId()));
if (componentEntity == null) {
- ErrorCode invalidComputeIdErrorBuilder =
- DeploymentFlavorErrorBuilder.getInvalidComponentIdErrorBuilder();
+ ErrorCode invalidComputeIdErrorBuilder = DeploymentFlavorErrorBuilder.getInvalidComponentIdErrorBuilder();
throw new CoreException(invalidComputeIdErrorBuilder);
}
}
}
- private void validateComponentComputeAssociationFlavour(
- DeploymentFlavorEntity deploymentFlavorEntity,
- Version version,
- ComponentComputeAssociation componentComputeAssociation) {
- if (componentComputeAssociation
- .getComputeFlavorId() != null && componentComputeAssociation
- .getComputeFlavorId().trim().length() > 0) {
- ComputeEntity computeFlavor = computeDao.get(new ComputeEntity(deploymentFlavorEntity
- .getVspId(), version, componentComputeAssociation.getComponentId(),
- componentComputeAssociation.getComputeFlavorId()));
- if (computeFlavor == null) {
- ErrorCode invalidComputeIdErrorBuilder = DeploymentFlavorErrorBuilder
- .getInvalidComputeIdErrorBuilder();
- throw new CoreException(invalidComputeIdErrorBuilder);
- }
+ private void validateComponentComputeAssociationFlavour(DeploymentFlavorEntity deploymentFlavorEntity, Version version,
+ ComponentComputeAssociation componentComputeAssociation) {
+ if (componentComputeAssociation.getComputeFlavorId() != null && componentComputeAssociation.getComputeFlavorId().trim().length() > 0) {
+ ComputeEntity computeFlavor = computeDao.get(
+ new ComputeEntity(deploymentFlavorEntity.getVspId(), version, componentComputeAssociation.getComponentId(),
+ componentComputeAssociation.getComputeFlavorId()));
+ if (computeFlavor == null) {
+ ErrorCode invalidComputeIdErrorBuilder = DeploymentFlavorErrorBuilder.getInvalidComputeIdErrorBuilder();
+ throw new CoreException(invalidComputeIdErrorBuilder);
+ }
+ }
}
- }
-
- @Override
- public CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavor(String vspId,
- Version version,
- String deploymentFlavorId) {
- DeploymentFlavorEntity deploymentFlavorEntity =
- getValidatedDeploymentFlavor(vspId, version, deploymentFlavorId);
- DeploymentFlavor deploymentFlavor = deploymentFlavorEntity.getDeploymentFlavorCompositionData();
- DeploymentFlavorCompositionSchemaInput schemaInput = new
- DeploymentFlavorCompositionSchemaInput();
- schemaInput.setManual(vspInfoDao.isManual(vspId, version));
- schemaInput.setDeploymentFlavor(deploymentFlavor);
- List<String> featureGroups =
- getFeatureGroupListForVsp(vspId, version);
- schemaInput.setFeatureGroupIds(featureGroups);
- CompositionEntityResponse<DeploymentFlavor> response = new CompositionEntityResponse<>();
- response.setId(deploymentFlavorId);
- response.setSchema(SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.deployment,
- schemaInput));
- response.setData(deploymentFlavor);
- return response;
- }
-
- private DeploymentFlavorEntity getValidatedDeploymentFlavor(String vspId, Version version, String
- deploymentFlavorId) {
- DeploymentFlavorEntity retrieved = deploymentFlavorDao.get(new DeploymentFlavorEntity(vspId,
- version, deploymentFlavorId));
- VersioningUtil
- .validateEntityExistence(retrieved, new DeploymentFlavorEntity(vspId, version,
- deploymentFlavorId), VspDetails.ENTITY_TYPE);
- return retrieved;
- }
- @Override
- public CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavorSchema(String vspId,
- Version version) {
- DeploymentFlavorCompositionSchemaInput schemaInput =
- new DeploymentFlavorCompositionSchemaInput();
- schemaInput.setManual(vspInfoDao.isManual(vspId, version));
- List<String> featureGroups =
- getFeatureGroupListForVsp(vspId, version);
- schemaInput.setFeatureGroupIds(featureGroups);
- CompositionEntityResponse<DeploymentFlavor> response = new CompositionEntityResponse<>();
- response.setSchema(SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.deployment,
- schemaInput));
- return response;
- }
-
- @Override
- public void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId) {
- DeploymentFlavorEntity deploymentFlavorEntity =
- getValidatedDeploymentFlavor(vspId, version, deploymentFlavorId);
- if (!vspInfoDao.isManual(vspId, version)) {
- final ErrorCode deleteDeploymentFlavorErrorBuilder =
- NotSupportedHeatOnboardMethodErrorBuilder
- .getDelDeploymentFlavorNotSupportedHeatOnboardMethodErrorBuilder();
- throw new CoreException(deleteDeploymentFlavorErrorBuilder);
+ @Override
+ public CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavor(String vspId, Version version, String deploymentFlavorId) {
+ DeploymentFlavorEntity deploymentFlavorEntity = getValidatedDeploymentFlavor(vspId, version, deploymentFlavorId);
+ DeploymentFlavor deploymentFlavor = deploymentFlavorEntity.getDeploymentFlavorCompositionData();
+ DeploymentFlavorCompositionSchemaInput schemaInput = new DeploymentFlavorCompositionSchemaInput();
+ schemaInput.setManual(vspInfoDao.isManual(vspId, version));
+ schemaInput.setDeploymentFlavor(deploymentFlavor);
+ List<String> featureGroups = getFeatureGroupListForVsp(vspId, version);
+ schemaInput.setFeatureGroupIds(featureGroups);
+ CompositionEntityResponse<DeploymentFlavor> response = new CompositionEntityResponse<>();
+ response.setId(deploymentFlavorId);
+ response.setSchema(SchemaGenerator.generate(SchemaTemplateContext.composition, CompositionEntityType.deployment, schemaInput));
+ response.setData(deploymentFlavor);
+ return response;
}
- if (deploymentFlavorEntity != null) {
- deploymentFlavorDao.delete(new DeploymentFlavorEntity(vspId, version, deploymentFlavorId));
+ private DeploymentFlavorEntity getValidatedDeploymentFlavor(String vspId, Version version, String deploymentFlavorId) {
+ DeploymentFlavorEntity retrieved = deploymentFlavorDao.get(new DeploymentFlavorEntity(vspId, version, deploymentFlavorId));
+ VersioningUtil.validateEntityExistence(retrieved, new DeploymentFlavorEntity(vspId, version, deploymentFlavorId), VspDetails.ENTITY_TYPE);
+ return retrieved;
}
- }
- @Override
- public CompositionEntityValidationData updateDeploymentFlavor(
- DeploymentFlavorEntity deploymentFlavorEntity) {
- if (!vspInfoDao.isManual(deploymentFlavorEntity.getVspId(),
- deploymentFlavorEntity.getVersion())) {
- final ErrorCode updateDeploymentFlavorErrorBuilder =
- NotSupportedHeatOnboardMethodErrorBuilder
- .getUpdateDfNotSupportedHeatOnboardMethodErrorBuilder();
- throw new CoreException(updateDeploymentFlavorErrorBuilder);
+ @Override
+ public CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavorSchema(String vspId, Version version) {
+ DeploymentFlavorCompositionSchemaInput schemaInput = new DeploymentFlavorCompositionSchemaInput();
+ schemaInput.setManual(vspInfoDao.isManual(vspId, version));
+ List<String> featureGroups = getFeatureGroupListForVsp(vspId, version);
+ schemaInput.setFeatureGroupIds(featureGroups);
+ CompositionEntityResponse<DeploymentFlavor> response = new CompositionEntityResponse<>();
+ response.setSchema(SchemaGenerator.generate(SchemaTemplateContext.composition, CompositionEntityType.deployment, schemaInput));
+ return response;
}
- DeploymentFlavorEntity retrieved =
- getValidatedDeploymentFlavor(deploymentFlavorEntity.getVspId(),
- deploymentFlavorEntity.getVersion(),
- deploymentFlavorEntity.getId());
-
-
- Collection<DeploymentFlavorEntity> listDeploymentFlavors = listDeploymentFlavors(
- deploymentFlavorEntity.getVspId(), deploymentFlavorEntity.getVersion());
- listDeploymentFlavors.remove(retrieved);
- isDeploymentFlavorModelDuplicate(deploymentFlavorEntity, listDeploymentFlavors);
- validateComponentComputeAssociation(deploymentFlavorEntity,
- deploymentFlavorEntity.getVersion());
-
- DeploymentFlavorCompositionSchemaInput schemaInput = new
- DeploymentFlavorCompositionSchemaInput();
- schemaInput.setManual(vspInfoDao.isManual(deploymentFlavorEntity.getVspId(),
- deploymentFlavorEntity.getVersion()));
- schemaInput.setDeploymentFlavor(retrieved.getDeploymentFlavorCompositionData());
+ @Override
+ public void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId) {
+ DeploymentFlavorEntity deploymentFlavorEntity = getValidatedDeploymentFlavor(vspId, version, deploymentFlavorId);
+ if (!vspInfoDao.isManual(vspId, version)) {
+ final ErrorCode deleteDeploymentFlavorErrorBuilder = NotSupportedHeatOnboardMethodErrorBuilder
+ .getDelDeploymentFlavorNotSupportedHeatOnboardMethodErrorBuilder();
+ throw new CoreException(deleteDeploymentFlavorErrorBuilder);
+ }
+ if (deploymentFlavorEntity != null) {
+ deploymentFlavorDao.delete(new DeploymentFlavorEntity(vspId, version, deploymentFlavorId));
+ }
+ }
- List<String> featureGroups =
- getFeatureGroupListForVsp(deploymentFlavorEntity.getVspId(),
+ @Override
+ public CompositionEntityValidationData updateDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity) {
+ if (!vspInfoDao.isManual(deploymentFlavorEntity.getVspId(), deploymentFlavorEntity.getVersion())) {
+ final ErrorCode updateDeploymentFlavorErrorBuilder = NotSupportedHeatOnboardMethodErrorBuilder
+ .getUpdateDfNotSupportedHeatOnboardMethodErrorBuilder();
+ throw new CoreException(updateDeploymentFlavorErrorBuilder);
+ }
+ DeploymentFlavorEntity retrieved = getValidatedDeploymentFlavor(deploymentFlavorEntity.getVspId(), deploymentFlavorEntity.getVersion(),
+ deploymentFlavorEntity.getId());
+ Collection<DeploymentFlavorEntity> listDeploymentFlavors = listDeploymentFlavors(deploymentFlavorEntity.getVspId(),
deploymentFlavorEntity.getVersion());
- schemaInput.setFeatureGroupIds(featureGroups);
-
- CompositionEntityValidationData validationData = compositionEntityDataManager
- .validateEntity(deploymentFlavorEntity, SchemaTemplateContext.composition, schemaInput);
- if (CollectionUtils.isEmpty(validationData.getErrors())) {
- deploymentFlavorDao.update(deploymentFlavorEntity);
+ listDeploymentFlavors.remove(retrieved);
+ isDeploymentFlavorModelDuplicate(deploymentFlavorEntity, listDeploymentFlavors);
+ validateComponentComputeAssociation(deploymentFlavorEntity, deploymentFlavorEntity.getVersion());
+ DeploymentFlavorCompositionSchemaInput schemaInput = new DeploymentFlavorCompositionSchemaInput();
+ schemaInput.setManual(vspInfoDao.isManual(deploymentFlavorEntity.getVspId(), deploymentFlavorEntity.getVersion()));
+ schemaInput.setDeploymentFlavor(retrieved.getDeploymentFlavorCompositionData());
+ List<String> featureGroups = getFeatureGroupListForVsp(deploymentFlavorEntity.getVspId(), deploymentFlavorEntity.getVersion());
+ schemaInput.setFeatureGroupIds(featureGroups);
+ CompositionEntityValidationData validationData = compositionEntityDataManager
+ .validateEntity(deploymentFlavorEntity, SchemaTemplateContext.composition, schemaInput);
+ if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ deploymentFlavorDao.update(deploymentFlavorEntity);
+ }
+ return validationData;
}
- return validationData;
- }
-
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerFactoryImpl.java
index 5972d49614..061e344a92 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerFactoryImpl.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,10 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-
import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.ImageManager;
import org.openecomp.sdc.vendorsoftwareproduct.ImageManagerFactory;
@@ -29,16 +27,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoF
public class ImageManagerFactoryImpl extends ImageManagerFactory {
- private static final ImageManager INSTANCE =
- new ImageManagerImpl(
- VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
- ImageDaoFactory.getInstance().createInterface(),
- CompositionEntityDataManagerFactory.getInstance().createInterface()
- );
-
- @Override
- public ImageManager createInterface() {
- return INSTANCE;
- }
+ private static final ImageManager INSTANCE = new ImageManagerImpl(VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
+ ImageDaoFactory.getInstance().createInterface(), CompositionEntityDataManagerFactory.getInstance().createInterface());
+ @Override
+ public ImageManager createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java
index 1e547d33ce..c4245d742d 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java
@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-
+import java.util.Collection;
+import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.common.errors.CoreException;
@@ -44,215 +44,166 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTempl
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Collection;
-import java.util.stream.Collectors;
-
public class ImageManagerImpl implements ImageManager {
- private final VendorSoftwareProductInfoDao vspInfoDao;
- private final ImageDao imageDao;
- private final CompositionEntityDataManager compositionEntityDataManager;
- public ImageManagerImpl(VendorSoftwareProductInfoDao vspInfoDao,
- ImageDao imageDao,
- CompositionEntityDataManager compositionEntityDataManager) {
- this.vspInfoDao = vspInfoDao;
- this.imageDao = imageDao;
- this.compositionEntityDataManager = compositionEntityDataManager;
- }
+ private final VendorSoftwareProductInfoDao vspInfoDao;
+ private final ImageDao imageDao;
+ private final CompositionEntityDataManager compositionEntityDataManager;
- @Override
- public ImageEntity createImage(ImageEntity imageEntity) {
- boolean isManual = vspInfoDao.isManual(imageEntity.getVspId(), imageEntity.getVersion());
- if (!isManual) {
- ErrorCode errorCode = NotSupportedHeatOnboardMethodErrorBuilder
- .getAddImageNotSupportedHeatOnboardMethodErrorBuilder();
- throw new CoreException(errorCode);
+ public ImageManagerImpl(VendorSoftwareProductInfoDao vspInfoDao, ImageDao imageDao, CompositionEntityDataManager compositionEntityDataManager) {
+ this.vspInfoDao = vspInfoDao;
+ this.imageDao = imageDao;
+ this.compositionEntityDataManager = compositionEntityDataManager;
}
- compositionEntityDataManager.createImage(imageEntity);
- return imageEntity;
- }
-
- @Override
- public Collection<ImageEntity> listImages(String vspId, Version version, String componentId) {
- return imageDao.list(new ImageEntity(vspId, version, componentId, null));
- }
-
- @Override
- public CompositionEntityResponse<Image> getImageSchema(String vspId) {
- CompositionEntityResponse<Image> response = new CompositionEntityResponse<>();
- ImageCompositionSchemaInput inputSchema = new ImageCompositionSchemaInput();
- Image image = new Image();
- inputSchema.setImage(image);
- response.setSchema(getImageCompositionSchema(inputSchema));
- return response;
- }
- @Override
- public CompositionEntityResponse<Image> getImage(String vspId, Version version, String
- componentId, String imageId) {
- ImageEntity imageEntity = getImageEntity(vspId, version, componentId, imageId);
-
- Image image = imageEntity.getImageCompositionData();
-
- ImageCompositionSchemaInput schemaInput = new ImageCompositionSchemaInput();
- schemaInput.setImage(image);
-
- CompositionEntityResponse<Image> response = new CompositionEntityResponse<>();
- response.setId(imageId);
- response.setData(image);
- response.setSchema(getImageCompositionSchema(schemaInput));
- return response;
- }
-
- @Override
- public QuestionnaireResponse getImageQuestionnaire(String vspId, Version version, String
- componentId, String imageId) {
- QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
-
- ImageEntity retrieved = imageDao.getQuestionnaireData(vspId, version, componentId, imageId);
- VersioningUtil.validateEntityExistence(retrieved, new ImageEntity(vspId, version, componentId,
- imageId), ComponentEntity.ENTITY_TYPE);
- questionnaireResponse.setData(retrieved.getQuestionnaireData());
- questionnaireResponse.setSchema(getImageQuestionnaireSchema(null));
- return questionnaireResponse;
- }
-
- @Override
- public void deleteImage(String vspId, Version version, String componentId, String imageId) {
- ImageEntity imageEntity = getImageEntity(vspId, version, componentId, imageId);
- if (!vspInfoDao.isManual(vspId, version)) {
- final ErrorCode deleteImageErrorBuilder =
- NotSupportedHeatOnboardMethodErrorBuilder
- .getDelImageNotSupportedHeatOnboardMethodErrorBuilder();
- throw new CoreException(deleteImageErrorBuilder);
+ @Override
+ public ImageEntity createImage(ImageEntity imageEntity) {
+ boolean isManual = vspInfoDao.isManual(imageEntity.getVspId(), imageEntity.getVersion());
+ if (!isManual) {
+ ErrorCode errorCode = NotSupportedHeatOnboardMethodErrorBuilder.getAddImageNotSupportedHeatOnboardMethodErrorBuilder();
+ throw new CoreException(errorCode);
+ }
+ compositionEntityDataManager.createImage(imageEntity);
+ return imageEntity;
}
- if (imageEntity != null) {
- imageDao.delete(new ImageEntity(vspId, version, componentId, imageId));
- }
- }
- private void validateHeatVspImageUpdate(String name, String value, String retrievedValue) {
- if (value != null && !value.equals(retrievedValue)) {
- final ErrorCode updateHeatImageErrorBuilder =
- ImageErrorBuilder.getImageHeatReadOnlyErrorBuilder(name);
- throw new CoreException(updateHeatImageErrorBuilder);
+ @Override
+ public Collection<ImageEntity> listImages(String vspId, Version version, String componentId) {
+ return imageDao.list(new ImageEntity(vspId, version, componentId, null));
}
- }
-
- @Override
- public CompositionEntityValidationData updateImage(ImageEntity image) {
- boolean isManual = vspInfoDao.isManual(image.getVspId(), image.getVersion());
- ImageEntity retrieved =
- getImageEntity(image.getVspId(), image.getVersion(), image.getComponentId(),
- image.getId());
- Collection<ImageEntity> vfcImageList = listImages(image.getVspId(),
- image.getVersion(), image.getComponentId());
-
- //Set to null so that retrieved object is equal to one in list and gets removed.
- retrieved.setQuestionnaireData(null);
- vfcImageList.remove(retrieved);
-
-
- ImageCompositionSchemaInput schemaInput = new ImageCompositionSchemaInput();
- schemaInput.setManual(isManual);
- schemaInput.setImage(retrieved.getImageCompositionData());
-
- CompositionEntityValidationData validationData = compositionEntityDataManager
- .validateEntity(image, SchemaTemplateContext.composition, schemaInput);
- if (CollectionUtils.isEmpty(validationData.getErrors())) {
- imageDao.update(image);
+ @Override
+ public CompositionEntityResponse<Image> getImageSchema(String vspId) {
+ CompositionEntityResponse<Image> response = new CompositionEntityResponse<>();
+ ImageCompositionSchemaInput inputSchema = new ImageCompositionSchemaInput();
+ Image image = new Image();
+ inputSchema.setImage(image);
+ response.setSchema(getImageCompositionSchema(inputSchema));
+ return response;
}
- return validationData;
- }
- @Override
- public void updateImageQuestionnaire(String vspId, Version version, String componentId, String
- imageId, String questionnaireData) {
- getImageEntity(vspId, version, componentId, imageId);
-
-
- final ImageDetails image = JsonUtil.json2Object(questionnaireData, ImageDetails.class);
- final String format = image.getFormat();
- try {
- if (format != null) {
- ImageFormat.valueOf(format);
- }
- } catch (IllegalArgumentException exception) {
- ErrorCode errorCode = ImageErrorBuilder.getInvalidImageFormatErrorBuilder();
- throw new CoreException(errorCode, exception);
+ @Override
+ public CompositionEntityResponse<Image> getImage(String vspId, Version version, String componentId, String imageId) {
+ ImageEntity imageEntity = getImageEntity(vspId, version, componentId, imageId);
+ Image image = imageEntity.getImageCompositionData();
+ ImageCompositionSchemaInput schemaInput = new ImageCompositionSchemaInput();
+ schemaInput.setImage(image);
+ CompositionEntityResponse<Image> response = new CompositionEntityResponse<>();
+ response.setId(imageId);
+ response.setData(image);
+ response.setSchema(getImageCompositionSchema(schemaInput));
+ return response;
}
- //Validate Format is read only for HEAT Onboarding
- if (!vspInfoDao.isManual(vspId, version)) {
- final QuestionnaireResponse imageQuestionnaire = getImageQuestionnaire(vspId, version,
- componentId, imageId);
- final String data = imageQuestionnaire.getData();
- if (data != null) {
- String retrievedFormat = JsonUtil.json2Object(data, ImageDetails.class).getFormat();
- validateHeatVspImageUpdate("format", format, retrievedFormat);
- }
+ @Override
+ public QuestionnaireResponse getImageQuestionnaire(String vspId, Version version, String componentId, String imageId) {
+ QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
+ ImageEntity retrieved = imageDao.getQuestionnaireData(vspId, version, componentId, imageId);
+ VersioningUtil.validateEntityExistence(retrieved, new ImageEntity(vspId, version, componentId, imageId), ComponentEntity.ENTITY_TYPE);
+ questionnaireResponse.setData(retrieved.getQuestionnaireData());
+ questionnaireResponse.setSchema(getImageQuestionnaireSchema(null));
+ return questionnaireResponse;
}
- if (!isImageVersionUnique(vspId, version, componentId, imageId, image)) {
- ErrorCode errorCode = ImageErrorBuilder.getDuplicateImageVersionErrorBuilder(image
- .getVersion(), componentId);
- throw new CoreException(errorCode);
+ @Override
+ public void deleteImage(String vspId, Version version, String componentId, String imageId) {
+ ImageEntity imageEntity = getImageEntity(vspId, version, componentId, imageId);
+ if (!vspInfoDao.isManual(vspId, version)) {
+ final ErrorCode deleteImageErrorBuilder = NotSupportedHeatOnboardMethodErrorBuilder
+ .getDelImageNotSupportedHeatOnboardMethodErrorBuilder();
+ throw new CoreException(deleteImageErrorBuilder);
+ }
+ if (imageEntity != null) {
+ imageDao.delete(new ImageEntity(vspId, version, componentId, imageId));
+ }
}
- imageDao.updateQuestionnaireData(vspId, version, componentId, imageId, questionnaireData);
- }
-
- private boolean isImageVersionUnique(String vspId, Version version, String componentId,
- String imageId,
- ImageDetails image) {
- boolean isPresent = true;
- if (image != null && image.getVersion() != null) {
- Collection<ImageEntity> imageEntities =
- imageDao.list(new ImageEntity(vspId, version, componentId, null));
- if (CollectionUtils.isNotEmpty(imageEntities)) {
- imageEntities =
- imageEntities.stream().filter(imageEntity -> image.getVersion().trim().equalsIgnoreCase(
- getImageVersion(vspId, version, componentId, imageEntity))
- && !imageEntity.getId().equals(imageId)).collect(Collectors.toList());
-
- isPresent = CollectionUtils.isEmpty(imageEntities);
- }
+ private void validateHeatVspImageUpdate(String name, String value, String retrievedValue) {
+ if (value != null && !value.equals(retrievedValue)) {
+ final ErrorCode updateHeatImageErrorBuilder = ImageErrorBuilder.getImageHeatReadOnlyErrorBuilder(name);
+ throw new CoreException(updateHeatImageErrorBuilder);
+ }
}
- return isPresent;
- }
-
- private String getImageVersion(String vspId, Version version, String componentId,
- ImageEntity imageEntity) {
- QuestionnaireResponse imageQuestionnaire = getImageQuestionnaire(vspId, version,
- componentId, imageEntity.getId());
- ImageDetails imageDetails =
- JsonUtil.json2Object(imageQuestionnaire.getData(), ImageDetails.class);
+ @Override
+ public CompositionEntityValidationData updateImage(ImageEntity image) {
+ boolean isManual = vspInfoDao.isManual(image.getVspId(), image.getVersion());
+ ImageEntity retrieved = getImageEntity(image.getVspId(), image.getVersion(), image.getComponentId(), image.getId());
+ Collection<ImageEntity> vfcImageList = listImages(image.getVspId(), image.getVersion(), image.getComponentId());
+ //Set to null so that retrieved object is equal to one in list and gets removed.
+ retrieved.setQuestionnaireData(null);
+ vfcImageList.remove(retrieved);
+ ImageCompositionSchemaInput schemaInput = new ImageCompositionSchemaInput();
+ schemaInput.setManual(isManual);
+ schemaInput.setImage(retrieved.getImageCompositionData());
+ CompositionEntityValidationData validationData = compositionEntityDataManager
+ .validateEntity(image, SchemaTemplateContext.composition, schemaInput);
+ if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ imageDao.update(image);
+ }
+ return validationData;
+ }
- return imageDetails == null ? null
- : imageDetails.getVersion() != null ? imageDetails.getVersion().trim() : null;
- }
+ @Override
+ public void updateImageQuestionnaire(String vspId, Version version, String componentId, String imageId, String questionnaireData) {
+ getImageEntity(vspId, version, componentId, imageId);
+ final ImageDetails image = JsonUtil.json2Object(questionnaireData, ImageDetails.class);
+ final String format = image.getFormat();
+ try {
+ if (format != null) {
+ ImageFormat.valueOf(format);
+ }
+ } catch (IllegalArgumentException exception) {
+ ErrorCode errorCode = ImageErrorBuilder.getInvalidImageFormatErrorBuilder();
+ throw new CoreException(errorCode, exception);
+ }
+ //Validate Format is read only for HEAT Onboarding
+ if (!vspInfoDao.isManual(vspId, version)) {
+ final QuestionnaireResponse imageQuestionnaire = getImageQuestionnaire(vspId, version, componentId, imageId);
+ final String data = imageQuestionnaire.getData();
+ if (data != null) {
+ String retrievedFormat = JsonUtil.json2Object(data, ImageDetails.class).getFormat();
+ validateHeatVspImageUpdate("format", format, retrievedFormat);
+ }
+ }
+ if (!isImageVersionUnique(vspId, version, componentId, imageId, image)) {
+ ErrorCode errorCode = ImageErrorBuilder.getDuplicateImageVersionErrorBuilder(image.getVersion(), componentId);
+ throw new CoreException(errorCode);
+ }
+ imageDao.updateQuestionnaireData(vspId, version, componentId, imageId, questionnaireData);
+ }
- private ImageEntity getImageEntity(String vspId, Version version, String componentId,
- String imageId) {
+ private boolean isImageVersionUnique(String vspId, Version version, String componentId, String imageId, ImageDetails image) {
+ boolean isPresent = true;
+ if (image != null && image.getVersion() != null) {
+ Collection<ImageEntity> imageEntities = imageDao.list(new ImageEntity(vspId, version, componentId, null));
+ if (CollectionUtils.isNotEmpty(imageEntities)) {
+ imageEntities = imageEntities.stream().filter(
+ imageEntity -> image.getVersion().trim().equalsIgnoreCase(getImageVersion(vspId, version, componentId, imageEntity))
+ && !imageEntity.getId().equals(imageId)).collect(Collectors.toList());
+ isPresent = CollectionUtils.isEmpty(imageEntities);
+ }
+ }
+ return isPresent;
+ }
- ImageEntity imageEntity = imageDao.get(new ImageEntity(vspId, version, componentId, imageId));
+ private String getImageVersion(String vspId, Version version, String componentId, ImageEntity imageEntity) {
+ QuestionnaireResponse imageQuestionnaire = getImageQuestionnaire(vspId, version, componentId, imageEntity.getId());
+ ImageDetails imageDetails = JsonUtil.json2Object(imageQuestionnaire.getData(), ImageDetails.class);
+ return imageDetails == null ? null : imageDetails.getVersion() != null ? imageDetails.getVersion().trim() : null;
+ }
- VersioningUtil.validateEntityExistence(imageEntity, new ImageEntity(vspId, version, componentId,
- imageId), VspDetails.ENTITY_TYPE);
- return imageEntity;
- }
+ private ImageEntity getImageEntity(String vspId, Version version, String componentId, String imageId) {
+ ImageEntity imageEntity = imageDao.get(new ImageEntity(vspId, version, componentId, imageId));
+ VersioningUtil.validateEntityExistence(imageEntity, new ImageEntity(vspId, version, componentId, imageId), VspDetails.ENTITY_TYPE);
+ return imageEntity;
+ }
- protected String getImageCompositionSchema(SchemaTemplateInput schemaInput) {
- return SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.image,
- schemaInput);
- }
+ protected String getImageCompositionSchema(SchemaTemplateInput schemaInput) {
+ return SchemaGenerator.generate(SchemaTemplateContext.composition, CompositionEntityType.image, schemaInput);
+ }
- protected String getImageQuestionnaireSchema(SchemaTemplateInput schemaInput) {
- return SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.image,
- schemaInput);
- }
+ protected String getImageQuestionnaireSchema(SchemaTemplateInput schemaInput) {
+ return SchemaGenerator.generate(SchemaTemplateContext.questionnaire, CompositionEntityType.image, schemaInput);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
index 58cb2cf2d6..e7697aad35 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
@@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.sdc.generator.core.services.ManualVspToscaGenerationService;
import org.openecomp.sdc.generator.datatypes.tosca.DeploymentFlavorModel;
@@ -29,84 +31,73 @@ import org.openecomp.sdc.vendorsoftwareproduct.services.ManualVspDataCollectionS
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
- private static final Logger LOGGER = LoggerFactory.getLogger(ManualVspToscaManagerImpl.class);
-
- private final ManualVspDataCollectionService
- manualVspDataCollectionService = new ManualVspDataCollectionService();
-
- @Override
- public VspModelInfo gatherVspInformation(String vspId, Version version) {
- VspModelInfo vspModelInfo = new VspModelInfo();
- //Get Release Vendor Name
- Optional<String> releaseVendor;
- try {
- releaseVendor = manualVspDataCollectionService.getReleaseVendor(vspId, version);
- } catch (Exception ex) {
- releaseVendor = Optional.empty();
- LOGGER.error("Failed to get release vendor: {}", ex.getMessage(), ex);
- }
- releaseVendor.ifPresent(vspModelInfo::setReleaseVendor);
-
- //Get Allowed Deployment flavors information
- Map<String, DeploymentFlavorModel> allowedFlavors;
- try {
- allowedFlavors = manualVspDataCollectionService.getAllowedFlavors(vspId, version);
- } catch (Exception ex) {
- allowedFlavors = null;
- LOGGER.error("Failed to get allowed flavours: {}", ex.getMessage(), ex);
- }
- if (MapUtils.isNotEmpty(allowedFlavors)) {
- vspModelInfo.setAllowedFlavors(allowedFlavors);
- }
-
- //Get VFC Image information
- Map<String, List<MultiFlavorVfcImage>> vspComponentImages;
- try {
- vspComponentImages =
- manualVspDataCollectionService.getVspComponentImages(vspId, version);
- } catch (Exception ex) {
- vspComponentImages = null;
- LOGGER.error("Failed to get VSP components Images: {}", ex.getMessage(), ex);
- }
- if (MapUtils.isNotEmpty(vspComponentImages)) {
- vspModelInfo.setMultiFlavorVfcImages(vspComponentImages);
- }
+ private static final Logger LOGGER = LoggerFactory.getLogger(ManualVspToscaManagerImpl.class);
+ private final ManualVspDataCollectionService manualVspDataCollectionService = new ManualVspDataCollectionService();
- //Get VFC component information
- Map<String, String> vspComponents;
- try {
- vspComponents = manualVspDataCollectionService.getVspComponents(vspId, version);
- } catch (Exception ex) {
- vspComponents = null;
- LOGGER.error("Failed to get VSP components: {}", ex.getMessage(), ex);
- }
- if (MapUtils.isNotEmpty(vspComponents)) {
- vspModelInfo.setComponents(vspComponents);
+ @Override
+ public VspModelInfo gatherVspInformation(String vspId, Version version) {
+ VspModelInfo vspModelInfo = new VspModelInfo();
+ //Get Release Vendor Name
+ Optional<String> releaseVendor;
+ try {
+ releaseVendor = manualVspDataCollectionService.getReleaseVendor(vspId, version);
+ } catch (Exception ex) {
+ releaseVendor = Optional.empty();
+ LOGGER.error("Failed to get release vendor: {}", ex.getMessage(), ex);
+ }
+ releaseVendor.ifPresent(vspModelInfo::setReleaseVendor);
+ //Get Allowed Deployment flavors information
+ Map<String, DeploymentFlavorModel> allowedFlavors;
+ try {
+ allowedFlavors = manualVspDataCollectionService.getAllowedFlavors(vspId, version);
+ } catch (Exception ex) {
+ allowedFlavors = null;
+ LOGGER.error("Failed to get allowed flavours: {}", ex.getMessage(), ex);
+ }
+ if (MapUtils.isNotEmpty(allowedFlavors)) {
+ vspModelInfo.setAllowedFlavors(allowedFlavors);
+ }
+ //Get VFC Image information
+ Map<String, List<MultiFlavorVfcImage>> vspComponentImages;
+ try {
+ vspComponentImages = manualVspDataCollectionService.getVspComponentImages(vspId, version);
+ } catch (Exception ex) {
+ vspComponentImages = null;
+ LOGGER.error("Failed to get VSP components Images: {}", ex.getMessage(), ex);
+ }
+ if (MapUtils.isNotEmpty(vspComponentImages)) {
+ vspModelInfo.setMultiFlavorVfcImages(vspComponentImages);
+ }
+ //Get VFC component information
+ Map<String, String> vspComponents;
+ try {
+ vspComponents = manualVspDataCollectionService.getVspComponents(vspId, version);
+ } catch (Exception ex) {
+ vspComponents = null;
+ LOGGER.error("Failed to get VSP components: {}", ex.getMessage(), ex);
+ }
+ if (MapUtils.isNotEmpty(vspComponents)) {
+ vspModelInfo.setComponents(vspComponents);
+ }
+ //Get VSP component nic information
+ Map<String, List<Nic>> vspComponentNics;
+ try {
+ vspComponentNics = manualVspDataCollectionService.getVspComponentNics(vspId, version);
+ } catch (Exception ex) {
+ vspComponentNics = null;
+ LOGGER.error("Failed to get VSP component NIC data: {}", ex.getMessage(), ex);
+ }
+ if (MapUtils.isNotEmpty(vspComponentNics)) {
+ vspModelInfo.setNics(vspComponentNics);
+ }
+ return vspModelInfo;
}
- //Get VSP component nic information
- Map<String, List<Nic>> vspComponentNics;
- try {
- vspComponentNics = manualVspDataCollectionService.getVspComponentNics(vspId, version);
- } catch (Exception ex) {
- vspComponentNics = null;
- LOGGER.error("Failed to get VSP component NIC data: {}", ex.getMessage(), ex);
+ @Override
+ public ToscaServiceModel generateToscaModel(VspModelInfo vspModelInfo) {
+ ManualVspToscaGenerationService vspToscaGenerator = new ManualVspToscaGenerationService();
+ return vspToscaGenerator.createManualVspToscaServiceModel(vspModelInfo);
}
- if (MapUtils.isNotEmpty(vspComponentNics)) {
- vspModelInfo.setNics(vspComponentNics);
- }
- return vspModelInfo;
- }
-
- @Override
- public ToscaServiceModel generateToscaModel(VspModelInfo vspModelInfo) {
- ManualVspToscaGenerationService vspToscaGenerator = new ManualVspToscaGenerationService();
- return vspToscaGenerator.createManualVspToscaServiceModel(vspModelInfo);
- }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java
index eed566de43..123de3dbd5 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManager;
@@ -25,11 +24,12 @@ import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.MonitoringUploadDaoFactory;
public class MonitoringUploadsManagerFactoryImpl extends MonitoringUploadsManagerFactory {
- private static final MonitoringUploadsManager INSTANCE =
- new MonitoringUploadsManagerImpl(MonitoringUploadDaoFactory.getInstance().createInterface());
- @Override
- public MonitoringUploadsManager createInterface() {
- return INSTANCE;
- }
+ private static final MonitoringUploadsManager INSTANCE = new MonitoringUploadsManagerImpl(
+ MonitoringUploadDaoFactory.getInstance().createInterface());
+
+ @Override
+ public MonitoringUploadsManager createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java
index 03ca76fd21..c4fed30e8e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java
@@ -13,9 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
+import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.enrichment.types.MonitoringUploadType;
import org.openecomp.core.utilities.CommonMethods;
@@ -39,171 +49,117 @@ import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.errors.VersionableSubEntityNotFoundErrorBuilder;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-import java.util.*;
-
-import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
-
public class MonitoringUploadsManagerImpl implements MonitoringUploadsManager {
- private final ComponentArtifactDao componentArtifactDao;
-
- MonitoringUploadsManagerImpl(ComponentArtifactDao componentArtifactDao) {
- this.componentArtifactDao = componentArtifactDao;
+ private final ComponentArtifactDao componentArtifactDao;
- componentArtifactDao.registerVersioning(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
- }
-
- @Override
- public void delete(String vspId, Version version, String componentId,
- MonitoringUploadType monitoringUploadType) {
- ComponentMonitoringUploadEntity componentMonitoringUploadEntity =
- setValuesForComponentArtifactEntityUpload(vspId, version, null, componentId, null,
- monitoringUploadType, null);
- Optional<ComponentMonitoringUploadEntity> retrieved = componentArtifactDao.getByType(
- componentMonitoringUploadEntity);
-
- if (!retrieved.isPresent()) {
- throw new CoreException(new VersionableSubEntityNotFoundErrorBuilder(
- componentMonitoringUploadEntity.getEntityType(),
- monitoringUploadType.name(),
- VspDetails.ENTITY_TYPE,
- componentMonitoringUploadEntity.getFirstClassCitizenId(),
- version).build());
+ MonitoringUploadsManagerImpl(ComponentArtifactDao componentArtifactDao) {
+ this.componentArtifactDao = componentArtifactDao;
+ componentArtifactDao.registerVersioning(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
}
- componentArtifactDao.delete(retrieved.get());
- }
-
- @Override
- public void upload(InputStream object, String filename, String vspId,
- Version version, String componentId,
- MonitoringUploadType type) {
- if (object == null) {
- throw new CoreException(new MonitoringUploadErrorBuilder(
- getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(),
- "zip")).build());
- } else {
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- try {
- byte[] uploadedFileData = FileUtils.toByteArray(object);
- final FileContentHandler upload =
- validateZip(vspId, version, uploadedFileData, errors);
- if (type.equals(MonitoringUploadType.VES_EVENTS)) {
- validateVesEventUpload(upload, errors);
- }
- if (MapUtils.isNotEmpty(errors)) {
- throw new CoreException(
- new MonitoringUploadErrorBuilder(
- errors.values().iterator().next().get(0).getMessage())
- .build());
+ @Override
+ public void delete(String vspId, Version version, String componentId, MonitoringUploadType monitoringUploadType) {
+ ComponentMonitoringUploadEntity componentMonitoringUploadEntity = setValuesForComponentArtifactEntityUpload(vspId, version, null, componentId,
+ null, monitoringUploadType, null);
+ Optional<ComponentMonitoringUploadEntity> retrieved = componentArtifactDao.getByType(componentMonitoringUploadEntity);
+ if (!retrieved.isPresent()) {
+ throw new CoreException(
+ new VersionableSubEntityNotFoundErrorBuilder(componentMonitoringUploadEntity.getEntityType(), monitoringUploadType.name(),
+ VspDetails.ENTITY_TYPE, componentMonitoringUploadEntity.getFirstClassCitizenId(), version).build());
}
-
- createArtifactInDatabase(vspId, version, filename, componentId, type,
- uploadedFileData);
-
- } catch (Exception exception) {
- throw new CoreException(new MonitoringUploadErrorBuilder(exception.getMessage()).build());
- }
+ componentArtifactDao.delete(retrieved.get());
}
- }
- private void validateVesEventUpload(FileContentHandler upload,
- Map<String, List<ErrorMessage>> errors) {
- if (!CommonUtil.validateAllFilesYml(upload)) {
- ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.UPLOAD_FILE, errors)
- .add(new ErrorMessage(ErrorLevel.ERROR,
- Messages.VES_ZIP_SHOULD_CONTAIN_YML_ONLY.getErrorMessage()));
- throw new CoreException(
- new MonitoringUploadErrorBuilder(
- Messages.VES_ZIP_SHOULD_CONTAIN_YML_ONLY.getErrorMessage())
- .build());
+ @Override
+ public void upload(InputStream object, String filename, String vspId, Version version, String componentId, MonitoringUploadType type) {
+ if (object == null) {
+ throw new CoreException(
+ new MonitoringUploadErrorBuilder(getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(), "zip"))
+ .build());
+ } else {
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ try {
+ byte[] uploadedFileData = FileUtils.toByteArray(object);
+ final FileContentHandler upload = validateZip(vspId, version, uploadedFileData, errors);
+ if (type.equals(MonitoringUploadType.VES_EVENTS)) {
+ validateVesEventUpload(upload, errors);
+ }
+ if (MapUtils.isNotEmpty(errors)) {
+ throw new CoreException(new MonitoringUploadErrorBuilder(errors.values().iterator().next().get(0).getMessage()).build());
+ }
+ createArtifactInDatabase(vspId, version, filename, componentId, type, uploadedFileData);
+ } catch (Exception exception) {
+ throw new CoreException(new MonitoringUploadErrorBuilder(exception.getMessage()).build());
+ }
+ }
}
- }
-
- private void createArtifactInDatabase(String vspId, Version version, String filename,
- String componentId,
- MonitoringUploadType type,
- byte[] uploadedFileData) {
- String artifactId = CommonMethods.nextUuId();
- ComponentMonitoringUploadEntity componentMonitoringUploadEntity =
- setValuesForComponentArtifactEntityUpload(vspId, version, filename, componentId,
- artifactId, type, uploadedFileData);
- componentArtifactDao.create(componentMonitoringUploadEntity);
- }
-
- @Override
- public MonitoringUploadStatus listFilenames(String vspId, Version version, String componentId) {
- ComponentMonitoringUploadEntity current =
- new ComponentMonitoringUploadEntity(vspId, version, componentId, null);
- return setMonitoringUploadStatusValues(current);
- }
-
- private MonitoringUploadStatus setMonitoringUploadStatusValues(
- ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
- MonitoringUploadStatus monitoringUploadStatus = new MonitoringUploadStatus();
-
- Collection<ComponentMonitoringUploadEntity> artifactNames =
- componentArtifactDao.list(componentMonitoringUploadEntity);
- Map<MonitoringUploadType, String> artifactTypeToFilename =
- VendorSoftwareProductUtils.mapArtifactsByType(artifactNames);
-
- if (MapUtils.isNotEmpty(artifactTypeToFilename)) {
- if (artifactTypeToFilename.containsKey(MonitoringUploadType.SNMP_TRAP)) {
- monitoringUploadStatus
- .setSnmpTrap(artifactTypeToFilename.get(MonitoringUploadType.SNMP_TRAP));
- }
- if (artifactTypeToFilename.containsKey(MonitoringUploadType.SNMP_POLL)) {
- monitoringUploadStatus
- .setSnmpPoll(artifactTypeToFilename.get(MonitoringUploadType.SNMP_POLL));
- }
- if (artifactTypeToFilename.containsKey(MonitoringUploadType.VES_EVENTS)) {
- monitoringUploadStatus
- .setVesEvent(artifactTypeToFilename.get(MonitoringUploadType.VES_EVENTS));
- }
+ private void validateVesEventUpload(FileContentHandler upload, Map<String, List<ErrorMessage>> errors) {
+ if (!CommonUtil.validateAllFilesYml(upload)) {
+ ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.UPLOAD_FILE, errors)
+ .add(new ErrorMessage(ErrorLevel.ERROR, Messages.VES_ZIP_SHOULD_CONTAIN_YML_ONLY.getErrorMessage()));
+ throw new CoreException(new MonitoringUploadErrorBuilder(Messages.VES_ZIP_SHOULD_CONTAIN_YML_ONLY.getErrorMessage()).build());
+ }
}
- return monitoringUploadStatus;
- }
-
- private ComponentMonitoringUploadEntity setValuesForComponentArtifactEntityUpload(
- String vspId, Version version, String filename, String componentId, String artifactId,
- MonitoringUploadType monitoringUploadType, byte[] uploadedFileData) {
-
- ComponentMonitoringUploadEntity
- entity = new ComponentMonitoringUploadEntity();
+ private void createArtifactInDatabase(String vspId, Version version, String filename, String componentId, MonitoringUploadType type,
+ byte[] uploadedFileData) {
+ String artifactId = CommonMethods.nextUuId();
+ ComponentMonitoringUploadEntity componentMonitoringUploadEntity = setValuesForComponentArtifactEntityUpload(vspId, version, filename,
+ componentId, artifactId, type, uploadedFileData);
+ componentArtifactDao.create(componentMonitoringUploadEntity);
+ }
- entity.setVspId(vspId);
- entity.setVersion(version);
- entity.setComponentId(componentId);
- entity.setId(artifactId);
- entity.setType(monitoringUploadType);
- entity.setArtifactName(filename);
+ @Override
+ public MonitoringUploadStatus listFilenames(String vspId, Version version, String componentId) {
+ ComponentMonitoringUploadEntity current = new ComponentMonitoringUploadEntity(vspId, version, componentId, null);
+ return setMonitoringUploadStatusValues(current);
+ }
- if (Objects.nonNull(uploadedFileData)) {
- entity.setArtifact(ByteBuffer.wrap(uploadedFileData));
+ private MonitoringUploadStatus setMonitoringUploadStatusValues(ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
+ MonitoringUploadStatus monitoringUploadStatus = new MonitoringUploadStatus();
+ Collection<ComponentMonitoringUploadEntity> artifactNames = componentArtifactDao.list(componentMonitoringUploadEntity);
+ Map<MonitoringUploadType, String> artifactTypeToFilename = VendorSoftwareProductUtils.mapArtifactsByType(artifactNames);
+ if (MapUtils.isNotEmpty(artifactTypeToFilename)) {
+ if (artifactTypeToFilename.containsKey(MonitoringUploadType.SNMP_TRAP)) {
+ monitoringUploadStatus.setSnmpTrap(artifactTypeToFilename.get(MonitoringUploadType.SNMP_TRAP));
+ }
+ if (artifactTypeToFilename.containsKey(MonitoringUploadType.SNMP_POLL)) {
+ monitoringUploadStatus.setSnmpPoll(artifactTypeToFilename.get(MonitoringUploadType.SNMP_POLL));
+ }
+ if (artifactTypeToFilename.containsKey(MonitoringUploadType.VES_EVENTS)) {
+ monitoringUploadStatus.setVesEvent(artifactTypeToFilename.get(MonitoringUploadType.VES_EVENTS));
+ }
+ }
+ return monitoringUploadStatus;
}
- return entity;
- }
+ private ComponentMonitoringUploadEntity setValuesForComponentArtifactEntityUpload(String vspId, Version version, String filename,
+ String componentId, String artifactId,
+ MonitoringUploadType monitoringUploadType,
+ byte[] uploadedFileData) {
+ ComponentMonitoringUploadEntity entity = new ComponentMonitoringUploadEntity();
+ entity.setVspId(vspId);
+ entity.setVersion(version);
+ entity.setComponentId(componentId);
+ entity.setId(artifactId);
+ entity.setType(monitoringUploadType);
+ entity.setArtifactName(filename);
+ if (Objects.nonNull(uploadedFileData)) {
+ entity.setArtifact(ByteBuffer.wrap(uploadedFileData));
+ }
+ return entity;
+ }
- private FileContentHandler validateZip(String vspId, Version version, byte[] uploadedFileData,
- Map<String, List<ErrorMessage>> errors) {
- FileContentHandler contentMap;
- try {
- contentMap =
- CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, uploadedFileData);
- VendorSoftwareProductUtils.validateContentZipData(contentMap, errors);
- } catch (IOException exception) {
- throw new CoreException(
- new MonitoringUploadErrorBuilder(vspId, version,
- Messages.INVALID_ZIP_FILE.getErrorMessage())
- .build());
+ private FileContentHandler validateZip(String vspId, Version version, byte[] uploadedFileData, Map<String, List<ErrorMessage>> errors) {
+ FileContentHandler contentMap;
+ try {
+ contentMap = CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, uploadedFileData);
+ VendorSoftwareProductUtils.validateContentZipData(contentMap, errors);
+ } catch (IOException exception) {
+ throw new CoreException(new MonitoringUploadErrorBuilder(vspId, version, Messages.INVALID_ZIP_FILE.getErrorMessage()).build());
+ }
+ return contentMap;
}
- return contentMap;
- }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerFactoryImpl.java
index 77501db298..83676a79e7 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerFactoryImpl.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManagerFactory;
@@ -27,14 +26,12 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
public class NetworkManagerFactoryImpl extends NetworkManagerFactory {
- private static final NetworkManager INSTANCE =
- new NetworkManagerImpl(
- NetworkDaoFactory.getInstance().createInterface(),
- CompositionEntityDataManagerFactory.getInstance().createInterface(),
- VendorSoftwareProductInfoDaoFactory.getInstance().createInterface());
- @Override
- public NetworkManager createInterface() {
- return INSTANCE;
- }
+ private static final NetworkManager INSTANCE = new NetworkManagerImpl(NetworkDaoFactory.getInstance().createInterface(),
+ CompositionEntityDataManagerFactory.getInstance().createInterface(), VendorSoftwareProductInfoDaoFactory.getInstance().createInterface());
+
+ @Override
+ public NetworkManager createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java
index 3d278d6934..7f50526fed 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java
@@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
+import java.util.Collection;
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManager;
@@ -35,88 +35,74 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTempl
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Collection;
-
public class NetworkManagerImpl implements NetworkManager {
- private final NetworkDao networkDao;
- private final CompositionEntityDataManager compositionEntityDataManager;
- private final VendorSoftwareProductInfoDao vspInfoDao;
- public NetworkManagerImpl(NetworkDao networkDao,
- CompositionEntityDataManager compositionEntityDataManager,
- VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao) {
- this.networkDao = networkDao;
- this.compositionEntityDataManager = compositionEntityDataManager;
- this.vspInfoDao = vendorSoftwareProductInfoDao;
- }
+ private final NetworkDao networkDao;
+ private final CompositionEntityDataManager compositionEntityDataManager;
+ private final VendorSoftwareProductInfoDao vspInfoDao;
- @Override
- public Collection<NetworkEntity> listNetworks(String vspId, Version version) {
- return networkDao.list(new NetworkEntity(vspId, version, null));
- }
-
- @Override
- public NetworkEntity createNetwork(NetworkEntity network) {
- if (!vspInfoDao.isManual(network.getVspId(), network.getVersion())) {
- throw new CoreException(
- new CompositionEditNotAllowedErrorBuilder(network.getVspId(), network.getVersion())
- .build());
+ public NetworkManagerImpl(NetworkDao networkDao, CompositionEntityDataManager compositionEntityDataManager,
+ VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao) {
+ this.networkDao = networkDao;
+ this.compositionEntityDataManager = compositionEntityDataManager;
+ this.vspInfoDao = vendorSoftwareProductInfoDao;
}
- return null;
- }
-
- @Override
- public CompositionEntityValidationData updateNetwork(NetworkEntity network) {
- NetworkEntity retrieved = getValidatedNetwork(network.getVspId(), network.getVersion(), network.getId());
-
- NetworkCompositionSchemaInput schemaInput = new NetworkCompositionSchemaInput();
- schemaInput.setManual(vspInfoDao.isManual(network.getVspId(), network.getVersion()));
- schemaInput.setNetwork(retrieved.getNetworkCompositionData());
- CompositionEntityValidationData validationData = compositionEntityDataManager
- .validateEntity(network, SchemaTemplateContext.composition, schemaInput);
- if (CollectionUtils.isEmpty(validationData.getErrors())) {
- networkDao.update(network);
+ @Override
+ public Collection<NetworkEntity> listNetworks(String vspId, Version version) {
+ return networkDao.list(new NetworkEntity(vspId, version, null));
}
- return validationData;
- }
- @Override
- public CompositionEntityResponse<Network> getNetwork(String vspId, Version version,
- String networkId) {
- NetworkEntity networkEntity = getValidatedNetwork(vspId, version, networkId);
- Network network = networkEntity.getNetworkCompositionData();
-
- NetworkCompositionSchemaInput schemaInput = new NetworkCompositionSchemaInput();
- schemaInput.setManual(vspInfoDao.isManual(vspId, version));
- schemaInput.setNetwork(network);
-
- CompositionEntityResponse<Network> response = new CompositionEntityResponse<>();
- response.setId(networkId);
- response.setData(network);
- response.setSchema(getCompositionSchema(schemaInput));
- return response;
- }
+ @Override
+ public NetworkEntity createNetwork(NetworkEntity network) {
+ if (!vspInfoDao.isManual(network.getVspId(), network.getVersion())) {
+ throw new CoreException(new CompositionEditNotAllowedErrorBuilder(network.getVspId(), network.getVersion()).build());
+ }
+ return null;
+ }
+ @Override
+ public CompositionEntityValidationData updateNetwork(NetworkEntity network) {
+ NetworkEntity retrieved = getValidatedNetwork(network.getVspId(), network.getVersion(), network.getId());
+ NetworkCompositionSchemaInput schemaInput = new NetworkCompositionSchemaInput();
+ schemaInput.setManual(vspInfoDao.isManual(network.getVspId(), network.getVersion()));
+ schemaInput.setNetwork(retrieved.getNetworkCompositionData());
+ CompositionEntityValidationData validationData = compositionEntityDataManager
+ .validateEntity(network, SchemaTemplateContext.composition, schemaInput);
+ if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ networkDao.update(network);
+ }
+ return validationData;
+ }
- private NetworkEntity getValidatedNetwork(String vspId, Version version, String networkId) {
- NetworkEntity retrieved = networkDao.get(new NetworkEntity(vspId, version, networkId));
- VersioningUtil.validateEntityExistence(retrieved, new NetworkEntity(vspId, version, networkId),
- VspDetails.ENTITY_TYPE);
- return retrieved;
- }
+ @Override
+ public CompositionEntityResponse<Network> getNetwork(String vspId, Version version, String networkId) {
+ NetworkEntity networkEntity = getValidatedNetwork(vspId, version, networkId);
+ Network network = networkEntity.getNetworkCompositionData();
+ NetworkCompositionSchemaInput schemaInput = new NetworkCompositionSchemaInput();
+ schemaInput.setManual(vspInfoDao.isManual(vspId, version));
+ schemaInput.setNetwork(network);
+ CompositionEntityResponse<Network> response = new CompositionEntityResponse<>();
+ response.setId(networkId);
+ response.setData(network);
+ response.setSchema(getCompositionSchema(schemaInput));
+ return response;
+ }
- @Override
- public void deleteNetwork(String vspId, Version version, String networkId) {
- if (!vspInfoDao.isManual(vspId, version)) {
- throw new CoreException(
- new CompositionEditNotAllowedErrorBuilder(vspId, version).build());
+ private NetworkEntity getValidatedNetwork(String vspId, Version version, String networkId) {
+ NetworkEntity retrieved = networkDao.get(new NetworkEntity(vspId, version, networkId));
+ VersioningUtil.validateEntityExistence(retrieved, new NetworkEntity(vspId, version, networkId), VspDetails.ENTITY_TYPE);
+ return retrieved;
}
- }
+ @Override
+ public void deleteNetwork(String vspId, Version version, String networkId) {
+ if (!vspInfoDao.isManual(vspId, version)) {
+ throw new CoreException(new CompositionEditNotAllowedErrorBuilder(vspId, version).build());
+ }
+ }
- protected String getCompositionSchema(NetworkCompositionSchemaInput schemaInput) {
- return SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.network, schemaInput);
- }
+ protected String getCompositionSchema(NetworkCompositionSchemaInput schemaInput) {
+ return SchemaGenerator.generate(SchemaTemplateContext.composition, CompositionEntityType.network, schemaInput);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerFactoryImpl.java
index 234dc09ebe..5dd5ccbc9c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerFactoryImpl.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManagerFactory;
@@ -28,15 +27,13 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
public class NicManagerFactoryImpl extends NicManagerFactory {
- private static final NicManager INSTANCE =
- new NicManagerImpl(
- NicDaoFactory.getInstance().createInterface(),
- CompositionEntityDataManagerFactory.getInstance().createInterface(),
- NetworkManagerFactory.getInstance().createInterface(),
- VendorSoftwareProductInfoDaoFactory.getInstance().createInterface());
- @Override
- public NicManager createInterface() {
- return INSTANCE;
- }
+ private static final NicManager INSTANCE = new NicManagerImpl(NicDaoFactory.getInstance().createInterface(),
+ CompositionEntityDataManagerFactory.getInstance().createInterface(), NetworkManagerFactory.getInstance().createInterface(),
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface());
+
+ @Override
+ public NicManager createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java
index 0ed58a7703..0cf85d3acd 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java
@@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCode;
@@ -28,7 +30,12 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.errors.*;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.DeleteNicErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.DuplicateNicInComponentErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NicErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NicInternalNetworkErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NicNetworkIdNotAllowedExternalNetworkErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NotSupportedHeatOnboardMethodErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
@@ -42,202 +49,162 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTempl
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Collection;
-import java.util.Map;
-import java.util.stream.Collectors;
-
public class NicManagerImpl implements NicManager {
- private final NicDao nicDao;
- private final CompositionEntityDataManager compositionEntityDataManager;
- private final NetworkManager networkManager;
- private final VendorSoftwareProductInfoDao vspInfoDao;
-
- public NicManagerImpl(NicDao nicDao,
- CompositionEntityDataManager compositionEntityDataManager,
- NetworkManager networkManager,
- VendorSoftwareProductInfoDao vspInfoDao) {
- this.nicDao = nicDao;
- this.compositionEntityDataManager = compositionEntityDataManager;
- this.networkManager = networkManager;
- this.vspInfoDao = vspInfoDao;
- }
-
- @Override
- public Collection<NicEntity> listNics(String vspId, Version version, String componentId) {
- Collection<NicEntity> nics = nicDao.list(new NicEntity(vspId, version, componentId, null));
-
- if (!nics.isEmpty()) {
- Map<String, String> networksNameById = listNetworksNameById(vspId, version);
- nics.forEach(nicEntity -> {
- Nic nic = nicEntity.getNicCompositionData();
- nic.setNetworkName(networksNameById.get(nic.getNetworkId()));
- nicEntity.setNicCompositionData(nic);
- });
+
+ private final NicDao nicDao;
+ private final CompositionEntityDataManager compositionEntityDataManager;
+ private final NetworkManager networkManager;
+ private final VendorSoftwareProductInfoDao vspInfoDao;
+
+ public NicManagerImpl(NicDao nicDao, CompositionEntityDataManager compositionEntityDataManager, NetworkManager networkManager,
+ VendorSoftwareProductInfoDao vspInfoDao) {
+ this.nicDao = nicDao;
+ this.compositionEntityDataManager = compositionEntityDataManager;
+ this.networkManager = networkManager;
+ this.vspInfoDao = vspInfoDao;
}
- return nics;
- }
-
- private Map<String, String> listNetworksNameById(String vspId, Version version) {
- Collection<NetworkEntity> networks = networkManager.listNetworks(vspId, version);
- return networks.stream().collect(Collectors.toMap(NetworkEntity::getId,
- networkEntity -> networkEntity.getNetworkCompositionData().getName()));
- }
-
- @Override
- public NicEntity createNic(NicEntity nic) {
- NicEntity createdNic;
- if (!vspInfoDao.isManual(nic.getVspId(), nic.getVersion())) {
- ErrorCode onboardingMethodUpdateErrorCode = NotSupportedHeatOnboardMethodErrorBuilder
- .getAddNicNotSupportedHeatOnboardMethodErrorBuilder();
- throw new CoreException(onboardingMethodUpdateErrorCode);
- } else {
- validateNic(nic);
- createdNic = compositionEntityDataManager.createNic(nic);
+
+ @Override
+ public Collection<NicEntity> listNics(String vspId, Version version, String componentId) {
+ Collection<NicEntity> nics = nicDao.list(new NicEntity(vspId, version, componentId, null));
+ if (!nics.isEmpty()) {
+ Map<String, String> networksNameById = listNetworksNameById(vspId, version);
+ nics.forEach(nicEntity -> {
+ Nic nic = nicEntity.getNicCompositionData();
+ nic.setNetworkName(networksNameById.get(nic.getNetworkId()));
+ nicEntity.setNicCompositionData(nic);
+ });
+ }
+ return nics;
}
- return createdNic;
- }
-
-
- private void validateNic(NicEntity nic) {
- Collection<NicEntity> listNics = listNics(nic.getVspId(), nic.getVersion(), nic
- .getComponentId());
- String networkId = nic.getNicCompositionData().getNetworkId();
- NetworkType networkType = nic.getNicCompositionData().getNetworkType();
- String networkDescription = nic.getNicCompositionData().getNetworkDescription();
-
- if (!nic.getNicCompositionData().getName()
- .matches(VendorSoftwareProductConstants.NAME_PATTERN)) {
- ErrorCode errorCode = NicErrorBuilder
- .getNicNameFormatErrorBuilder(VendorSoftwareProductConstants.NAME_PATTERN);
- throw new CoreException(errorCode);
+
+ private Map<String, String> listNetworksNameById(String vspId, Version version) {
+ Collection<NetworkEntity> networks = networkManager.listNetworks(vspId, version);
+ return networks.stream()
+ .collect(Collectors.toMap(NetworkEntity::getId, networkEntity -> networkEntity.getNetworkCompositionData().getName()));
}
- validateNics(nic, listNics);
+ @Override
+ public NicEntity createNic(NicEntity nic) {
+ NicEntity createdNic;
+ if (!vspInfoDao.isManual(nic.getVspId(), nic.getVersion())) {
+ ErrorCode onboardingMethodUpdateErrorCode = NotSupportedHeatOnboardMethodErrorBuilder
+ .getAddNicNotSupportedHeatOnboardMethodErrorBuilder();
+ throw new CoreException(onboardingMethodUpdateErrorCode);
+ } else {
+ validateNic(nic);
+ createdNic = compositionEntityDataManager.createNic(nic);
+ }
+ return createdNic;
+ }
+
+ private void validateNic(NicEntity nic) {
+ Collection<NicEntity> listNics = listNics(nic.getVspId(), nic.getVersion(), nic.getComponentId());
+ String networkId = nic.getNicCompositionData().getNetworkId();
+ NetworkType networkType = nic.getNicCompositionData().getNetworkType();
+ String networkDescription = nic.getNicCompositionData().getNetworkDescription();
+ if (!nic.getNicCompositionData().getName().matches(VendorSoftwareProductConstants.NAME_PATTERN)) {
+ ErrorCode errorCode = NicErrorBuilder.getNicNameFormatErrorBuilder(VendorSoftwareProductConstants.NAME_PATTERN);
+ throw new CoreException(errorCode);
+ }
+ validateNics(nic, listNics);
+ if (networkType.equals(NetworkType.Internal)) {
+ validateInternalNetworkType(nic, networkId, networkDescription);
+ } else if (networkType.equals(NetworkType.External) && !(networkId == null || networkId.isEmpty())) {
+ final ErrorCode nicNetworkIdNotAllowedExternalNetworkErrorBuilder = new NicNetworkIdNotAllowedExternalNetworkErrorBuilder().build();
+ throw new CoreException(nicNetworkIdNotAllowedExternalNetworkErrorBuilder);
+ }
+ }
- if (networkType.equals(NetworkType.Internal)) {
- validateInternalNetworkType(nic, networkId, networkDescription);
+ private void validateInternalNetworkType(NicEntity nic, String networkId, String networkDescription) {
+ if (!(networkId == null || networkId.isEmpty())) {
+ networkManager.getNetwork(nic.getVspId(), nic.getVersion(), networkId);
+ }
+ if (!(networkDescription == null || networkDescription.isEmpty())) {
+ final ErrorCode nicNetworkDescriptionErrorBuilder = NicInternalNetworkErrorBuilder.getNetworkDescriptionInternalNetworkErrorBuilder();
+ throw new CoreException(nicNetworkDescriptionErrorBuilder);
+ }
+ }
+
+ private void validateNics(NicEntity nic, Collection<NicEntity> listNics) {
+ listNics.forEach(nicEntity -> {
+ Nic nicdata = nicEntity.getNicCompositionData();
+ if (nic.getNicCompositionData().getName().equalsIgnoreCase(nicdata.getName())) {
+ final ErrorCode duplicateNicInComponentErrorBuilder = new DuplicateNicInComponentErrorBuilder(nic.getNicCompositionData().getName(),
+ nic.getComponentId()).build();
+ throw new CoreException(duplicateNicInComponentErrorBuilder);
+ }
+ });
+ }
- } else if (networkType.equals(NetworkType.External)
- && !(networkId == null || networkId.isEmpty())) {
- final ErrorCode nicNetworkIdNotAllowedExternalNetworkErrorBuilder =
- new NicNetworkIdNotAllowedExternalNetworkErrorBuilder().build();
- throw new CoreException(nicNetworkIdNotAllowedExternalNetworkErrorBuilder);
+ @Override
+ public CompositionEntityResponse<Nic> getNic(String vspId, Version version, String componentId, String nicId) {
+ NicEntity nicEntity = getValidatedNic(vspId, version, componentId, nicId);
+ Nic nic = nicEntity.getNicCompositionData();
+ NicCompositionSchemaInput schemaInput = new NicCompositionSchemaInput();
+ schemaInput.setManual(vspInfoDao.isManual(vspId, version));
+ schemaInput.setNic(nic);
+ Map<String, String> networksNameById = listNetworksNameById(vspId, version);
+ nic.setNetworkName(networksNameById.get(nic.getNetworkId()));
+ schemaInput.setNetworkIds(networksNameById.keySet());
+ CompositionEntityResponse<Nic> response = new CompositionEntityResponse<>();
+ response.setId(nicId);
+ response.setData(nic);
+ response.setSchema(getNicCompositionSchema(schemaInput));
+ return response;
}
- }
- private void validateInternalNetworkType(NicEntity nic, String networkId,
- String networkDescription) {
- if (!(networkId == null || networkId.isEmpty())) {
- networkManager.getNetwork(nic.getVspId(), nic.getVersion(), networkId);
+ private NicEntity getValidatedNic(String vspId, Version version, String componentId, String nicId) {
+ NicEntity retrieved = nicDao.get(new NicEntity(vspId, version, componentId, nicId));
+ VersioningUtil.validateEntityExistence(retrieved, new NicEntity(vspId, version, componentId, nicId), VspDetails.ENTITY_TYPE);
+ return retrieved;
}
- if (!(networkDescription == null || networkDescription.isEmpty())) {
- final ErrorCode nicNetworkDescriptionErrorBuilder =
- NicInternalNetworkErrorBuilder.getNetworkDescriptionInternalNetworkErrorBuilder();
- throw new CoreException(nicNetworkDescriptionErrorBuilder);
+ @Override
+ public void deleteNic(String vspId, Version version, String componentId, String nicId) {
+ if (!vspInfoDao.isManual(vspId, version)) {
+ final ErrorCode deleteNicErrorBuilder = DeleteNicErrorBuilder.getDeleteNicForHeatOnboardedVspErrorBuilder();
+ throw new CoreException(deleteNicErrorBuilder);
+ }
+ NicEntity nicEntity = getValidatedNic(vspId, version, componentId, nicId);
+ nicDao.delete(nicEntity);
}
- }
-
- private void validateNics(NicEntity nic, Collection<NicEntity> listNics) {
- listNics.forEach(nicEntity -> {
- Nic nicdata = nicEntity.getNicCompositionData();
- if (nic.getNicCompositionData().getName().equalsIgnoreCase(nicdata.getName())) {
- final ErrorCode duplicateNicInComponentErrorBuilder =
- new DuplicateNicInComponentErrorBuilder(nic.getNicCompositionData().getName(),
- nic.getComponentId()).build();
- throw new CoreException(duplicateNicInComponentErrorBuilder);
- }
-
- });
- }
-
- @Override
- public CompositionEntityResponse<Nic> getNic(String vspId, Version version, String componentId,
- String nicId) {
- NicEntity nicEntity = getValidatedNic(vspId, version, componentId, nicId);
- Nic nic = nicEntity.getNicCompositionData();
-
- NicCompositionSchemaInput schemaInput = new NicCompositionSchemaInput();
- schemaInput.setManual(vspInfoDao.isManual(vspId, version));
- schemaInput.setNic(nic);
- Map<String, String> networksNameById = listNetworksNameById(vspId, version);
- nic.setNetworkName(networksNameById.get(nic.getNetworkId()));
- schemaInput.setNetworkIds(networksNameById.keySet());
-
- CompositionEntityResponse<Nic> response = new CompositionEntityResponse<>();
- response.setId(nicId);
- response.setData(nic);
- response.setSchema(getNicCompositionSchema(schemaInput));
- return response;
- }
-
-
- private NicEntity getValidatedNic(String vspId, Version version, String componentId,
- String nicId) {
- NicEntity retrieved = nicDao.get(new NicEntity(vspId, version, componentId, nicId));
- VersioningUtil
- .validateEntityExistence(retrieved, new NicEntity(vspId, version, componentId, nicId),
- VspDetails.ENTITY_TYPE);
- return retrieved;
- }
-
- @Override
- public void deleteNic(String vspId, Version version, String componentId, String nicId) {
- if (!vspInfoDao.isManual(vspId, version)) {
- final ErrorCode deleteNicErrorBuilder =
- DeleteNicErrorBuilder.getDeleteNicForHeatOnboardedVspErrorBuilder();
- throw new CoreException(deleteNicErrorBuilder);
+
+ @Override
+ public CompositionEntityValidationData updateNic(NicEntity nic) {
+ NicEntity retrieved = getValidatedNic(nic.getVspId(), nic.getVersion(), nic.getComponentId(), nic.getId());
+ NicCompositionSchemaInput schemaInput = new NicCompositionSchemaInput();
+ schemaInput.setManual(vspInfoDao.isManual(nic.getVspId(), nic.getVersion()));
+ schemaInput.setNic(retrieved.getNicCompositionData());
+ CompositionEntityValidationData validationData = compositionEntityDataManager
+ .validateEntity(nic, SchemaTemplateContext.composition, schemaInput);
+ if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ nicDao.update(nic);
+ }
+ return validationData;
}
- NicEntity nicEntity = getValidatedNic(vspId, version, componentId, nicId);
- nicDao.delete(nicEntity);
- }
+ @Override
+ public QuestionnaireResponse getNicQuestionnaire(String vspId, Version version, String componentId, String nicId) {
+ QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
+ NicEntity nicQuestionnaire = nicDao.getQuestionnaireData(vspId, version, componentId, nicId);
+ VersioningUtil.validateEntityExistence(nicQuestionnaire, new NicEntity(vspId, version, componentId, nicId), VspDetails.ENTITY_TYPE);
+ questionnaireResponse.setData(nicQuestionnaire.getQuestionnaireData());
+ questionnaireResponse.setSchema(getNicQuestionnaireSchema(null));
+ return questionnaireResponse;
+ }
- @Override
- public CompositionEntityValidationData updateNic(NicEntity nic) {
- NicEntity retrieved =
- getValidatedNic(nic.getVspId(), nic.getVersion(), nic.getComponentId(), nic.getId());
+ @Override
+ public void updateNicQuestionnaire(String vspId, Version version, String componentId, String nicId, String questionnaireData) {
+ getNic(vspId, version, componentId, nicId);
+ nicDao.updateQuestionnaireData(vspId, version, componentId, nicId, questionnaireData);
+ }
- NicCompositionSchemaInput schemaInput = new NicCompositionSchemaInput();
- schemaInput.setManual(vspInfoDao.isManual(nic.getVspId(), nic.getVersion()));
- schemaInput.setNic(retrieved.getNicCompositionData());
+ protected String getNicQuestionnaireSchema(SchemaTemplateInput schemaInput) {
+ return SchemaGenerator.generate(SchemaTemplateContext.questionnaire, CompositionEntityType.nic, schemaInput);
+ }
- CompositionEntityValidationData validationData = compositionEntityDataManager
- .validateEntity(nic, SchemaTemplateContext.composition, schemaInput);
- if (CollectionUtils.isEmpty(validationData.getErrors())) {
- nicDao.update(nic);
+ protected String getNicCompositionSchema(NicCompositionSchemaInput schemaInput) {
+ return SchemaGenerator.generate(SchemaTemplateContext.composition, CompositionEntityType.nic, schemaInput);
}
- return validationData;
- }
-
- @Override
- public QuestionnaireResponse getNicQuestionnaire(String vspId, Version version,
- String componentId, String nicId) {
- QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
- NicEntity nicQuestionnaire = nicDao.getQuestionnaireData(vspId, version, componentId, nicId);
- VersioningUtil.validateEntityExistence(nicQuestionnaire,
- new NicEntity(vspId, version, componentId, nicId), VspDetails.ENTITY_TYPE);
-
- questionnaireResponse.setData(nicQuestionnaire.getQuestionnaireData());
- questionnaireResponse.setSchema(getNicQuestionnaireSchema(null));
- return questionnaireResponse;
- }
-
- @Override
- public void updateNicQuestionnaire(String vspId, Version version, String componentId,
- String nicId, String questionnaireData) {
- getNic(vspId, version, componentId, nicId);
-
- nicDao.updateQuestionnaireData(vspId, version, componentId, nicId, questionnaireData);
- }
-
- protected String getNicQuestionnaireSchema(SchemaTemplateInput schemaInput) {
- return SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.nic, schemaInput);
- }
-
- protected String getNicCompositionSchema(NicCompositionSchemaInput schemaInput) {
- return SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.nic, schemaInput);
- }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java
index ae0283b568..03b2654f2f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
@@ -21,17 +20,13 @@ import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateMan
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
-public class OrchestrationTemplateCandidateManagerFactoryImpl extends
- OrchestrationTemplateCandidateManagerFactory {
+public class OrchestrationTemplateCandidateManagerFactoryImpl extends OrchestrationTemplateCandidateManagerFactory {
- private static final OrchestrationTemplateCandidateManager INSTANCE =
- new OrchestrationTemplateCandidateManagerImpl(
- VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
- CandidateServiceFactory.getInstance().createInterface()
- );
+ private static final OrchestrationTemplateCandidateManager INSTANCE = new OrchestrationTemplateCandidateManagerImpl(
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(), CandidateServiceFactory.getInstance().createInterface());
- @Override
- public OrchestrationTemplateCandidateManager createInterface() {
- return INSTANCE;
- }
+ @Override
+ public OrchestrationTemplateCandidateManager createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
index d4c7151c17..7e576789d5 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import java.io.IOException;
@@ -47,108 +46,83 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
import org.openecomp.sdc.versioning.dao.types.Version;
-public class OrchestrationTemplateCandidateManagerImpl
- implements OrchestrationTemplateCandidateManager {
-
- private final VendorSoftwareProductInfoDao vspInfoDao;
- private final CandidateService candidateService;
+public class OrchestrationTemplateCandidateManagerImpl implements OrchestrationTemplateCandidateManager {
- public OrchestrationTemplateCandidateManagerImpl(VendorSoftwareProductInfoDao vspInfoDao,
- CandidateService candidateService
- ) {
- this.vspInfoDao = vspInfoDao;
- this.candidateService = candidateService;
- }
+ private final VendorSoftwareProductInfoDao vspInfoDao;
+ private final CandidateService candidateService;
- @Override
- public UploadFileResponse upload(final VspDetails vspDetails,
- final OnboardPackageInfo onboardPackageInfo) {
- final OnboardPackage onboardPackage = onboardPackageInfo.getOnboardPackage();
- final OrchestrationTemplateFileHandler orchestrationTemplateFileHandler =
- OrchestrationUploadFactory.createOrchestrationTemplateFileHandler(onboardPackageInfo.getPackageType());
-
- final UploadFileResponse uploadFileResponse =
- orchestrationTemplateFileHandler.upload(vspDetails, onboardPackageInfo, candidateService);
- uploadFileResponse.setNetworkPackageName(onboardPackage.getFilename());
- return uploadFileResponse;
- }
+ public OrchestrationTemplateCandidateManagerImpl(VendorSoftwareProductInfoDao vspInfoDao, CandidateService candidateService) {
+ this.vspInfoDao = vspInfoDao;
+ this.candidateService = candidateService;
+ }
- @Override
- public OrchestrationTemplateActionResponse process(String vspId, Version version) {
- OrchestrationTemplateCandidateData candidate =
- candidateService.getOrchestrationTemplateCandidate(vspId, version)
- .orElseThrow(() -> new CoreException(
- new OrchestrationTemplateNotFoundErrorBuilder(vspId).build()));
+ @Override
+ public UploadFileResponse upload(final VspDetails vspDetails, final OnboardPackageInfo onboardPackageInfo) {
+ final OnboardPackage onboardPackage = onboardPackageInfo.getOnboardPackage();
+ final OrchestrationTemplateFileHandler orchestrationTemplateFileHandler = OrchestrationUploadFactory
+ .createOrchestrationTemplateFileHandler(onboardPackageInfo.getPackageType());
+ final UploadFileResponse uploadFileResponse = orchestrationTemplateFileHandler.upload(vspDetails, onboardPackageInfo, candidateService);
+ uploadFileResponse.setNetworkPackageName(onboardPackage.getFilename());
+ return uploadFileResponse;
+ }
- return OrchestrationProcessFactory.getInstance(candidate.getFileSuffix())
- .map(processor -> processor.process(getVspDetails(vspId, version), candidate))
- .orElse(new OrchestrationTemplateActionResponse());
- }
+ @Override
+ public OrchestrationTemplateActionResponse process(String vspId, Version version) {
+ OrchestrationTemplateCandidateData candidate = candidateService.getOrchestrationTemplateCandidate(vspId, version)
+ .orElseThrow(() -> new CoreException(new OrchestrationTemplateNotFoundErrorBuilder(vspId).build()));
+ return OrchestrationProcessFactory.getInstance(candidate.getFileSuffix())
+ .map(processor -> processor.process(getVspDetails(vspId, version), candidate)).orElse(new OrchestrationTemplateActionResponse());
+ }
- @Override
- public Optional<FilesDataStructure> getFilesDataStructure(String vspId, Version version) {
- return candidateService.getOrchestrationTemplateCandidateFileDataStructure(vspId, version);
- }
+ @Override
+ public Optional<FilesDataStructure> getFilesDataStructure(String vspId, Version version) {
+ return candidateService.getOrchestrationTemplateCandidateFileDataStructure(vspId, version);
+ }
- @Override
- public ValidationResponse updateFilesDataStructure(String vspId, Version version,
- FilesDataStructure fileDataStructure) {
- ValidationResponse response = new ValidationResponse();
- Optional<List<ErrorMessage>> validateErrors =
- candidateService.validateFileDataStructure(fileDataStructure);
- if (validateErrors.isPresent()) {
- List<ErrorMessage> errorMessages = validateErrors.get();
- if (CollectionUtils.isNotEmpty(errorMessages)) {
- Map<String, List<ErrorMessage>> errorsMap = Collections.singletonMap(SdcCommon.UPLOAD_FILE, errorMessages);
- response.setUploadDataErrors(errorsMap);
+ @Override
+ public ValidationResponse updateFilesDataStructure(String vspId, Version version, FilesDataStructure fileDataStructure) {
+ ValidationResponse response = new ValidationResponse();
+ Optional<List<ErrorMessage>> validateErrors = candidateService.validateFileDataStructure(fileDataStructure);
+ if (validateErrors.isPresent()) {
+ List<ErrorMessage> errorMessages = validateErrors.get();
+ if (CollectionUtils.isNotEmpty(errorMessages)) {
+ Map<String, List<ErrorMessage>> errorsMap = Collections.singletonMap(SdcCommon.UPLOAD_FILE, errorMessages);
+ response.setUploadDataErrors(errorsMap);
+ return response;
+ }
+ }
+ candidateService.updateOrchestrationTemplateCandidateFileDataStructure(vspId, version, fileDataStructure);
return response;
- }
}
- candidateService
- .updateOrchestrationTemplateCandidateFileDataStructure(vspId, version, fileDataStructure);
- return response;
- }
- @Override
-
- public Optional<Pair<String, byte[]>> get(String vspId, Version version) throws IOException {
- VspDetails vspDetails = getVspDetails(vspId, version);
-
- Optional<OrchestrationTemplateCandidateData> candidateDataEntity =
- candidateService.getOrchestrationTemplateCandidate(vspId, version);
-
- if (!candidateDataEntity.isPresent()) {
- return Optional.empty();
+ @Override
+ public Optional<Pair<String, byte[]>> get(String vspId, Version version) throws IOException {
+ VspDetails vspDetails = getVspDetails(vspId, version);
+ Optional<OrchestrationTemplateCandidateData> candidateDataEntity = candidateService.getOrchestrationTemplateCandidate(vspId, version);
+ if (!candidateDataEntity.isPresent()) {
+ return Optional.empty();
+ }
+ if (CommonUtil.isFileOriginFromZip(candidateDataEntity.get().getFileSuffix())) {
+ FilesDataStructure structure = JsonUtil.json2Object(candidateDataEntity.get().getFilesDataStructure(), FilesDataStructure.class);
+ String manifest = candidateService.createManifest(vspDetails, structure);
+ OnboardingTypesEnum type = OnboardingTypesEnum.getOnboardingTypesEnum(candidateDataEntity.get().getFileSuffix());
+ return Optional.of(new ImmutablePair<>(OnboardingTypesEnum.ZIP.toString(),
+ candidateService.replaceManifestInZip(candidateDataEntity.get().getContentData(), manifest, type)));
+ }
+ return Optional.of(new ImmutablePair<>(candidateDataEntity.get().getFileSuffix(), candidateDataEntity.get().getContentData().array()));
}
- if (CommonUtil.isFileOriginFromZip(candidateDataEntity.get().getFileSuffix())) {
- FilesDataStructure structure = JsonUtil
- .json2Object(candidateDataEntity.get().getFilesDataStructure(), FilesDataStructure.class);
- String manifest = candidateService.createManifest(vspDetails, structure);
- OnboardingTypesEnum type =
- OnboardingTypesEnum.getOnboardingTypesEnum(candidateDataEntity.get().getFileSuffix());
- return Optional.of(
- new ImmutablePair<>(OnboardingTypesEnum.ZIP.toString(), candidateService
- .replaceManifestInZip(candidateDataEntity.get().getContentData(),
- manifest, type)));
+ @Override
+ public Optional<OrchestrationTemplateCandidateData> getInfo(String vspId, Version version) {
+ return candidateService.getOrchestrationTemplateCandidateInfo(vspId, version);
}
- return Optional.of(
- new ImmutablePair<>(candidateDataEntity.get().getFileSuffix(), candidateDataEntity.get()
- .getContentData().array()));
- }
-
- @Override
- public Optional<OrchestrationTemplateCandidateData> getInfo(String vspId, Version version) {
- return candidateService.getOrchestrationTemplateCandidateInfo(vspId, version);
- }
-
- @Override
- public void abort(String vspId, Version version) {
- candidateService.deleteOrchestrationTemplateCandidate(vspId, version);
- }
+ @Override
+ public void abort(String vspId, Version version) {
+ candidateService.deleteOrchestrationTemplateCandidate(vspId, version);
+ }
- private VspDetails getVspDetails(String vspId, Version version) {
- return vspInfoDao.get(new VspDetails(vspId, version));
- }
-} \ No newline at end of file
+ private VspDetails getVspDetails(String vspId, Version version) {
+ return vspInfoDao.get(new VspDetails(vspId, version));
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerFactoryImpl.java
index b1b8ff4d42..9f10df65a5 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerFactoryImpl.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.core.dao.UniqueValueDaoFactory;
@@ -26,12 +25,12 @@ import org.openecomp.sdc.vendorsoftwareproduct.ProcessManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
public class ProcessManagerFactoryImpl extends ProcessManagerFactory {
- private static final ProcessManager INSTANCE =
- new ProcessManagerImpl(ProcessDaoFactory.getInstance().createInterface(),
- UniqueValueDaoFactory.getInstance().createInterface());
- @Override
- public ProcessManager createInterface() {
- return INSTANCE;
- }
+ private static final ProcessManager INSTANCE = new ProcessManagerImpl(ProcessDaoFactory.getInstance().createInterface(),
+ UniqueValueDaoFactory.getInstance().createInterface());
+
+ @Override
+ public ProcessManager createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
index 855007dfd9..a5347350b0 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
@@ -13,9 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.Collection;
import org.openecomp.core.dao.UniqueValueDao;
import org.openecomp.core.util.UniqueValueUtil;
import org.openecomp.core.utilities.file.FileUtils;
@@ -31,191 +36,144 @@ import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-import java.util.Collection;
-
public class ProcessManagerImpl implements ProcessManager {
- private static final String PROCESS_ARTIFACT_NOT_EXIST_MSG =
- "Process artifact for process with Id %s does not exist for %s with Id %s and version %s";
- private final ProcessDao processDao;
- private final UniqueValueUtil uniqueValueUtil;
-
- public ProcessManagerImpl(ProcessDao processDao, UniqueValueDao uniqueValueDao) {
- this.processDao = processDao;
- this.uniqueValueUtil = new UniqueValueUtil(uniqueValueDao);
- }
-
- @Override
- public Collection<ProcessEntity> listProcesses(String vspId, Version version,
- String componentId) {
- return processDao.list(new ProcessEntity(vspId, version, componentId, null));
- }
-
- @Override
- public void deleteProcesses(String vspId, Version version, String componentId) {
- ProcessEntity allProcesses = new ProcessEntity(vspId, version, componentId, null);
- Collection<ProcessEntity> processes = processDao.list(allProcesses);
-
- if (!processes.isEmpty()) {
- for (ProcessEntity process : processes) {
- deleteUniqueValue(process.getVspId(), process.getVersion(), process.getComponentId(),
- process.getName());
- }
- }
-
- if (componentId == null) {
- processDao.deleteVspAll(vspId,version);
- } else {
- processDao.deleteAll(allProcesses);
- }
- }
-
- @Override
- public ProcessEntity createProcess(ProcessEntity process) {
- validateUniqueName(process.getVspId(), process.getVersion(), process.getComponentId(),
- process.getName());
-
- processDao.create(process);
- createUniqueName(process.getVspId(), process.getVersion(), process.getComponentId(),
- process.getName());
- return process;
- }
-
- @Override
- public ProcessEntity getProcess(String vspId, Version version, String componentId,
- String processId) {
- ProcessEntity retrieved =
- processDao.get(new ProcessEntity(vspId, version, componentId, processId));
- validateProcessExistence(vspId, version, componentId, processId, retrieved);
- return retrieved;
- }
-
- @Override
- public void updateProcess(ProcessEntity process) {
- ProcessEntity retrieved = processDao.get(process);
- validateProcessExistence(process.getVspId(), process.getVersion(), process.getComponentId(),
- process.getId(), retrieved);
-
- updateUniqueName(process.getVspId(), process.getVersion(), process.getComponentId(),
- retrieved.getName(), process.getName());
- processDao.update(process);
- }
-
- @Override
- public void deleteProcess(String vspId, Version version, String componentId, String processId) {
- ProcessEntity retrieved = getProcess(vspId, version, componentId, processId);
-
- processDao.delete(retrieved);
- deleteUniqueValue(retrieved.getVspId(), retrieved.getVersion(), retrieved.getComponentId(),
- retrieved.getName());
- }
-
-
- @Override
- public File getProcessArtifact(String vspId, Version version, String componentId,
- String processId) {
- ProcessEntity retrieved = getValidatedProcessArtifact(vspId, version, componentId, processId);
-
- File file = new File(String.format("%s_%s_%s", vspId, componentId, processId));
- try (FileOutputStream fos = new FileOutputStream(file)) {
- fos.write(retrieved.getArtifact().array());
- } catch (IOException exception) {
- throw new CoreException(new UploadInvalidErrorBuilder().build(), exception);
- }
- return file;
- }
-
- @Override
- public void deleteProcessArtifact(String vspId, Version version, String componentId,
- String processId) {
- ProcessEntity retrieved = getValidatedProcessArtifact(vspId, version, componentId, processId);
-
- processDao.deleteArtifact(retrieved);
- }
-
- @Override
- public void uploadProcessArtifact(InputStream artifactFile, String artifactFileName, String vspId,
- Version version, String componentId, String processId) {
- ProcessEntity process = getProcess(vspId, version, componentId, processId);
- process.setArtifactName(artifactFileName);
- process.setArtifact(readArtifact(artifactFile));
- processDao.uploadArtifact(process);
- }
-
- private ProcessEntity getValidatedProcessArtifact(String vspId, Version version,
- String componentId, String processId) {
- ProcessEntity retrieved =
- processDao.getArtifact(new ProcessEntity(vspId, version, componentId, processId));
- validateProcessArtifactExistence(vspId, version, componentId, processId, retrieved);
- return retrieved;
- }
-
- private ByteBuffer readArtifact(InputStream artifactInputStream) {
- if (artifactInputStream == null) {
- throw new CoreException(new UploadInvalidErrorBuilder().build());
- }
- try {
- return ByteBuffer.wrap(FileUtils.toByteArray(artifactInputStream));
- } catch (RuntimeException exception) {
- throw new CoreException(new UploadInvalidErrorBuilder().build(), exception);
- }
- }
-
-
- private void validateProcessExistence(String vspId, Version version, String componentId,
- String processId, ProcessEntity retrieved) {
- VersioningUtil.validateEntityExistence(retrieved,
- new ProcessEntity(vspId, version, componentId, processId),
- VspDetails.ENTITY_TYPE);
- }
-
- private void validateProcessArtifactExistence(String vspId, Version version, String componentId,
- String processId, ProcessEntity retrieved) {
- ProcessEntity inputProcess = new ProcessEntity(vspId, version, componentId, processId);
- VersioningUtil.validateEntityExistence(retrieved, inputProcess, VspDetails.ENTITY_TYPE);
- if (retrieved.getArtifact() == null) {
- throw new CoreException(new ErrorCode.ErrorCodeBuilder()
- .withId(VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND)
- .withMessage(String.format(PROCESS_ARTIFACT_NOT_EXIST_MSG,
- processId, VspDetails.ENTITY_TYPE, vspId, version)).build());
- }
- }
-
-
- protected void validateUniqueName(String vspId, Version version, String componentId,
- String processName) {
- uniqueValueUtil.validateUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME,
- vspId, version.getId(), componentId, processName);
- }
-
- protected void createUniqueName(String vspId, Version version, String componentId,
- String processName) {
- uniqueValueUtil
- .createUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, vspId,
- version.getId(), componentId, processName);
- }
-
- protected void updateUniqueName(String vspId, Version version, String componentId,
- String oldProcessName, String newProcessName) {
- uniqueValueUtil
- .updateUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, oldProcessName,
- newProcessName, vspId, version.getId(), componentId);
- }
-
- protected void deleteUniqueValue(String vspId, Version version, String componentId,
- String processName) {
- if (componentId == null) {
- uniqueValueUtil
- .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, vspId,
- version.getId(), processName);
- }
- uniqueValueUtil
- .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, vspId,
- version.getId(), componentId, processName);
- }
+ private static final String PROCESS_ARTIFACT_NOT_EXIST_MSG = "Process artifact for process with Id %s does not exist for %s with Id %s and version %s";
+ private final ProcessDao processDao;
+ private final UniqueValueUtil uniqueValueUtil;
+
+ public ProcessManagerImpl(ProcessDao processDao, UniqueValueDao uniqueValueDao) {
+ this.processDao = processDao;
+ this.uniqueValueUtil = new UniqueValueUtil(uniqueValueDao);
+ }
+
+ @Override
+ public Collection<ProcessEntity> listProcesses(String vspId, Version version, String componentId) {
+ return processDao.list(new ProcessEntity(vspId, version, componentId, null));
+ }
+
+ @Override
+ public void deleteProcesses(String vspId, Version version, String componentId) {
+ ProcessEntity allProcesses = new ProcessEntity(vspId, version, componentId, null);
+ Collection<ProcessEntity> processes = processDao.list(allProcesses);
+ if (!processes.isEmpty()) {
+ for (ProcessEntity process : processes) {
+ deleteUniqueValue(process.getVspId(), process.getVersion(), process.getComponentId(), process.getName());
+ }
+ }
+ if (componentId == null) {
+ processDao.deleteVspAll(vspId, version);
+ } else {
+ processDao.deleteAll(allProcesses);
+ }
+ }
+
+ @Override
+ public ProcessEntity createProcess(ProcessEntity process) {
+ validateUniqueName(process.getVspId(), process.getVersion(), process.getComponentId(), process.getName());
+ processDao.create(process);
+ createUniqueName(process.getVspId(), process.getVersion(), process.getComponentId(), process.getName());
+ return process;
+ }
+
+ @Override
+ public ProcessEntity getProcess(String vspId, Version version, String componentId, String processId) {
+ ProcessEntity retrieved = processDao.get(new ProcessEntity(vspId, version, componentId, processId));
+ validateProcessExistence(vspId, version, componentId, processId, retrieved);
+ return retrieved;
+ }
+
+ @Override
+ public void updateProcess(ProcessEntity process) {
+ ProcessEntity retrieved = processDao.get(process);
+ validateProcessExistence(process.getVspId(), process.getVersion(), process.getComponentId(), process.getId(), retrieved);
+ updateUniqueName(process.getVspId(), process.getVersion(), process.getComponentId(), retrieved.getName(), process.getName());
+ processDao.update(process);
+ }
+
+ @Override
+ public void deleteProcess(String vspId, Version version, String componentId, String processId) {
+ ProcessEntity retrieved = getProcess(vspId, version, componentId, processId);
+ processDao.delete(retrieved);
+ deleteUniqueValue(retrieved.getVspId(), retrieved.getVersion(), retrieved.getComponentId(), retrieved.getName());
+ }
+
+ @Override
+ public File getProcessArtifact(String vspId, Version version, String componentId, String processId) {
+ ProcessEntity retrieved = getValidatedProcessArtifact(vspId, version, componentId, processId);
+ File file = new File(String.format("%s_%s_%s", vspId, componentId, processId));
+ try (FileOutputStream fos = new FileOutputStream(file)) {
+ fos.write(retrieved.getArtifact().array());
+ } catch (IOException exception) {
+ throw new CoreException(new UploadInvalidErrorBuilder().build(), exception);
+ }
+ return file;
+ }
+
+ @Override
+ public void deleteProcessArtifact(String vspId, Version version, String componentId, String processId) {
+ ProcessEntity retrieved = getValidatedProcessArtifact(vspId, version, componentId, processId);
+ processDao.deleteArtifact(retrieved);
+ }
+
+ @Override
+ public void uploadProcessArtifact(InputStream artifactFile, String artifactFileName, String vspId, Version version, String componentId,
+ String processId) {
+ ProcessEntity process = getProcess(vspId, version, componentId, processId);
+ process.setArtifactName(artifactFileName);
+ process.setArtifact(readArtifact(artifactFile));
+ processDao.uploadArtifact(process);
+ }
+
+ private ProcessEntity getValidatedProcessArtifact(String vspId, Version version, String componentId, String processId) {
+ ProcessEntity retrieved = processDao.getArtifact(new ProcessEntity(vspId, version, componentId, processId));
+ validateProcessArtifactExistence(vspId, version, componentId, processId, retrieved);
+ return retrieved;
+ }
+
+ private ByteBuffer readArtifact(InputStream artifactInputStream) {
+ if (artifactInputStream == null) {
+ throw new CoreException(new UploadInvalidErrorBuilder().build());
+ }
+ try {
+ return ByteBuffer.wrap(FileUtils.toByteArray(artifactInputStream));
+ } catch (RuntimeException exception) {
+ throw new CoreException(new UploadInvalidErrorBuilder().build(), exception);
+ }
+ }
+
+ private void validateProcessExistence(String vspId, Version version, String componentId, String processId, ProcessEntity retrieved) {
+ VersioningUtil.validateEntityExistence(retrieved, new ProcessEntity(vspId, version, componentId, processId), VspDetails.ENTITY_TYPE);
+ }
+
+ private void validateProcessArtifactExistence(String vspId, Version version, String componentId, String processId, ProcessEntity retrieved) {
+ ProcessEntity inputProcess = new ProcessEntity(vspId, version, componentId, processId);
+ VersioningUtil.validateEntityExistence(retrieved, inputProcess, VspDetails.ENTITY_TYPE);
+ if (retrieved.getArtifact() == null) {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder().withId(VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND)
+ .withMessage(String.format(PROCESS_ARTIFACT_NOT_EXIST_MSG, processId, VspDetails.ENTITY_TYPE, vspId, version)).build());
+ }
+ }
+
+ protected void validateUniqueName(String vspId, Version version, String componentId, String processName) {
+ uniqueValueUtil
+ .validateUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, vspId, version.getId(), componentId, processName);
+ }
+
+ protected void createUniqueName(String vspId, Version version, String componentId, String processName) {
+ uniqueValueUtil.createUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, vspId, version.getId(), componentId, processName);
+ }
+
+ protected void updateUniqueName(String vspId, Version version, String componentId, String oldProcessName, String newProcessName) {
+ uniqueValueUtil
+ .updateUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, oldProcessName, newProcessName, vspId, version.getId(),
+ componentId);
+ }
+
+ protected void deleteUniqueValue(String vspId, Version version, String componentId, String processName) {
+ if (componentId == null) {
+ uniqueValueUtil.deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, vspId, version.getId(), processName);
+ }
+ uniqueValueUtil.deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, vspId, version.getId(), componentId, processName);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index 3f45885999..82b1d0a64c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder.candidateDataNotProcessedOrAbortedErrorBuilder;
@@ -141,6 +140,7 @@ import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductManager {
+
private static final Logger LOGGER = LoggerFactory.getLogger(VendorSoftwareProductManager.class);
private VspMergeDao vspMergeDao;
private OrchestrationTemplateDao orchestrationTemplateDao;
@@ -162,51 +162,42 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private UniqueValueUtil uniqueValueUtil;
private CandidateService candidateService;
+ private static ErrorCode createMissingMandatoryFieldError(String fieldName) {
+ return new ValidationErrorBuilder("must be supplied", fieldName).build();
+ }
+
@Override
public ValidationResponse validate(VspDetails vspDetails) throws IOException {
List<ErrorCode> vspErrors = new ArrayList<>(validateVspFields(vspDetails));
ValidationResponse validationResponse = new ValidationResponse();
- if (Objects.nonNull(vspDetails.getOnboardingMethod()) && OnboardingMethod.Manual.name()
- .equals(vspDetails.getOnboardingMethod())) {
+ if (Objects.nonNull(vspDetails.getOnboardingMethod()) && OnboardingMethod.Manual.name().equals(vspDetails.getOnboardingMethod())) {
validateManualOnboardingMethod(vspDetails, validationResponse, vspErrors);
} else {
- validateOrchestrationTemplateCandidate(validationResponse, vspErrors, vspDetails.getId(),
- vspDetails.getVersion());
+ validateOrchestrationTemplateCandidate(validationResponse, vspErrors, vspDetails.getId(), vspDetails.getVersion());
if (!validationResponse.isValid()) {
return validationResponse;
}
validateLicense(vspDetails, vspErrors);
- OrchestrationTemplateEntity orchestrationTemplate =
- orchestrationTemplateDao.get(vspDetails.getId(), vspDetails.getVersion());
- ToscaServiceModel serviceModel =
- serviceModelDao.getServiceModel(vspDetails.getId(), vspDetails.getVersion());
+ OrchestrationTemplateEntity orchestrationTemplate = orchestrationTemplateDao.get(vspDetails.getId(), vspDetails.getVersion());
+ ToscaServiceModel serviceModel = serviceModelDao.getServiceModel(vspDetails.getId(), vspDetails.getVersion());
if (isOrchestrationTemplateMissing(orchestrationTemplate) || isServiceModelMissing(serviceModel)) {
vspErrors.add(VendorSoftwareProductInvalidErrorBuilder
- .vendorSoftwareProductMissingServiceModelErrorBuilder(vspDetails.getId(),
- vspDetails.getVersion()));
+ .vendorSoftwareProductMissingServiceModelErrorBuilder(vspDetails.getId(), vspDetails.getVersion()));
}
validationResponse.setUploadDataErrors(validateOrchestrationTemplate(orchestrationTemplate));
}
-
- QuestionnaireValidationResult questionnaireValidationResult =
- validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion(), vspDetails.getOnboardingMethod());
-
+ QuestionnaireValidationResult questionnaireValidationResult = validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion(),
+ vspDetails.getOnboardingMethod());
if (Objects.nonNull(questionnaireValidationResult)) {
if (validationResponse.getQuestionnaireValidationResult() == null
- || validationResponse.getQuestionnaireValidationResult().getValidationData() == null) {
+ || validationResponse.getQuestionnaireValidationResult().getValidationData() == null) {
validationResponse.setQuestionnaireValidationResult(questionnaireValidationResult);
} else {
- validationResponse.getQuestionnaireValidationResult().getValidationData()
- .addAll(questionnaireValidationResult.getValidationData());
+ validationResponse.getQuestionnaireValidationResult().getValidationData().addAll(questionnaireValidationResult.getValidationData());
}
}
-
Collection<ComponentDependencyModelEntity> componentDependencies = componentDependencyModelDao
- .list(new ComponentDependencyModelEntity(
- vspDetails.getId(),
- vspDetails.getVersion(),
- null));
-
+ .list(new ComponentDependencyModelEntity(vspDetails.getId(), vspDetails.getVersion(), null));
if (validateComponentDependencies(componentDependencies)) {
vspErrors.add(ComponentDependencyModelErrorBuilder.getCyclicDependencyComponentErrorBuilder());
}
@@ -216,71 +207,58 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
private void validateLicense(VspDetails vspDetails, List<ErrorCode> vspErrors) {
- if (vspDetails.getVlmVersion() != null || vspDetails.getLicenseAgreement() != null
- || vspDetails.getFeatureGroups() != null) {
+ if (vspDetails.getVlmVersion() != null || vspDetails.getLicenseAgreement() != null || vspDetails.getFeatureGroups() != null) {
vspErrors.addAll(validateMandatoryLicenseFields(vspDetails));
}
}
- private void validateOrchestrationTemplateCandidate(ValidationResponse validationResponse,
- List<ErrorCode> vspErrors, String vspId, Version version) {
+ private void validateOrchestrationTemplateCandidate(ValidationResponse validationResponse, List<ErrorCode> vspErrors, String vspId,
+ Version version) {
orchestrationTemplateCandidateManager.getInfo(vspId, version).ifPresent(candidateInfo -> {
String fileName = candidateInfo.getFileName();
- vspErrors.add(candidateInfo.getValidationData().isEmpty() ? candidateDataNotProcessedOrAbortedErrorBuilder(
- fileName) : invalidProcessedCandidate(fileName));
+ vspErrors.add(candidateInfo.getValidationData().isEmpty() ? candidateDataNotProcessedOrAbortedErrorBuilder(fileName)
+ : invalidProcessedCandidate(fileName));
validationResponse.setVspErrors(vspErrors);
});
}
- private void validateManualOnboardingMethod(VspDetails vspDetails, ValidationResponse validationResponse,
- List<ErrorCode> vspErrors) {
+ private void validateManualOnboardingMethod(VspDetails vspDetails, ValidationResponse validationResponse, List<ErrorCode> vspErrors) {
vspErrors.addAll(validateMandatoryLicenseFields(vspDetails));
-
- Collection<DeploymentFlavorEntity> deploymentFlavors =
- deploymentFlavorDao.list(new DeploymentFlavorEntity(vspDetails.getId(), vspDetails.getVersion(), null));
+ Collection<DeploymentFlavorEntity> deploymentFlavors = deploymentFlavorDao
+ .list(new DeploymentFlavorEntity(vspDetails.getId(), vspDetails.getVersion(), null));
if (CollectionUtils.isEmpty(deploymentFlavors)) {
vspErrors.add(vspMissingDeploymentFlavorErrorBuilder());
}
vspErrors.addAll(validateDeploymentFlavors(deploymentFlavors));
-
- Set<CompositionEntityValidationData> componentValidationResult =
- componentValidation(vspDetails.getId(), vspDetails.getVersion());
+ Set<CompositionEntityValidationData> componentValidationResult = componentValidation(vspDetails.getId(), vspDetails.getVersion());
if (!CollectionUtils.isEmpty(componentValidationResult)) {
if (validationResponse.getQuestionnaireValidationResult() == null
- || validationResponse.getQuestionnaireValidationResult().getValidationData() == null) {
- validationResponse
- .setQuestionnaireValidationResult(new QuestionnaireValidationResult(componentValidationResult));
+ || validationResponse.getQuestionnaireValidationResult().getValidationData() == null) {
+ validationResponse.setQuestionnaireValidationResult(new QuestionnaireValidationResult(componentValidationResult));
} else {
- validationResponse.getQuestionnaireValidationResult().getValidationData()
- .addAll(componentValidationResult);
+ validationResponse.getQuestionnaireValidationResult().getValidationData().addAll(componentValidationResult);
}
}
}
@Override
public Map<String, List<ErrorMessage>> compile(String vspId, Version version) {
- ToscaServiceModel serviceModel =
- OnboardingMethod.Manual.name().equals(getValidatedVsp(vspId, version).getOnboardingMethod())
- //Generate Tosca service model for Manual Onboarding flow
- ? manualVspToscaManager
- .generateToscaModel(manualVspToscaManager.gatherVspInformation(vspId, version))
- : serviceModelDao.getServiceModel(vspId, version);
-
+ ToscaServiceModel serviceModel = OnboardingMethod.Manual.name().equals(getValidatedVsp(vspId, version).getOnboardingMethod())
+ //Generate Tosca service model for Manual Onboarding flow
+ ? manualVspToscaManager.generateToscaModel(manualVspToscaManager.gatherVspInformation(vspId, version))
+ : serviceModelDao.getServiceModel(vspId, version);
return compile(vspId, version, serviceModel);
}
private boolean validateComponentDependencies(Collection<ComponentDependencyModelEntity> componentDependencies) {
ComponentDependencyTracker dependencyTracker = new ComponentDependencyTracker();
-
for (ComponentDependencyModelEntity componentDependency : componentDependencies) {
- dependencyTracker.addDependency(componentDependency.getSourceComponentId(),
- componentDependency.getTargetComponentId());
+ dependencyTracker.addDependency(componentDependency.getSourceComponentId(), componentDependency.getTargetComponentId());
}
return dependencyTracker.isCyclicDependencyPresent();
}
private Collection<ErrorCode> validateDeploymentFlavors(Collection<DeploymentFlavorEntity> deploymentFlavors) {
-
Collection<ErrorCode> errorCodeList = new ArrayList<>();
if (!CollectionUtils.isEmpty(deploymentFlavors)) {
deploymentFlavors.forEach(deploymentFlavor -> {
@@ -288,32 +266,26 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
DeploymentFlavor deploymentLocalFlavor = deployment.getDeploymentFlavorCompositionData();
if (deploymentLocalFlavor != null) {
if (deploymentLocalFlavor.getFeatureGroupId() == null) {
- ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder.
- getFeatureGroupMandatoryErrorBuilder(
- deploymentLocalFlavor
- .getModel());
+ ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
+ .getFeatureGroupMandatoryErrorBuilder(deploymentLocalFlavor.getModel());
errorCodeList.add(deploymentFlavorErrorBuilder);
}
- validateComponentComputeAssociations(errorCodeList, deploymentFlavor, deployment,
- deploymentLocalFlavor);
+ validateComponentComputeAssociations(errorCodeList, deploymentFlavor, deployment, deploymentLocalFlavor);
}
});
}
return errorCodeList;
}
- private void validateComponentComputeAssociations(Collection<ErrorCode> errorCodeList,
- DeploymentFlavorEntity deploymentFlavor, DeploymentFlavorEntity deployment,
- DeploymentFlavor deploymentlocalFlavor) {
- List<ComponentComputeAssociation> componentComputeAssociations =
- deploymentlocalFlavor.getComponentComputeAssociations();
+ private void validateComponentComputeAssociations(Collection<ErrorCode> errorCodeList, DeploymentFlavorEntity deploymentFlavor,
+ DeploymentFlavorEntity deployment, DeploymentFlavor deploymentlocalFlavor) {
+ List<ComponentComputeAssociation> componentComputeAssociations = deploymentlocalFlavor.getComponentComputeAssociations();
if (CollectionUtils.isEmpty(componentComputeAssociations)) {
validateCompositionEntity(errorCodeList, deploymentFlavor, deployment, deploymentlocalFlavor);
} else {
componentComputeAssociations.forEach(componentComputeAssociation -> {
if (componentComputeAssociation == null || !(componentComputeAssociation.getComponentId() != null
- && componentComputeAssociation.getComputeFlavorId()
- != null)) {
+ && componentComputeAssociation.getComputeFlavorId() != null)) {
validateCompositionEntity(errorCodeList, deploymentFlavor, deployment, deploymentlocalFlavor);
}
});
@@ -321,13 +293,12 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
private void validateCompositionEntity(Collection<ErrorCode> errorCodeList, DeploymentFlavorEntity deploymentFlavor,
- DeploymentFlavorEntity deployment, DeploymentFlavor deploymentlocalFlavor) {
- CompositionEntityValidationData compositionEntityValidationData =
- new CompositionEntityValidationData(CompositionEntityType.deployment, deploymentFlavor.getId());
+ DeploymentFlavorEntity deployment, DeploymentFlavor deploymentlocalFlavor) {
+ CompositionEntityValidationData compositionEntityValidationData = new CompositionEntityValidationData(CompositionEntityType.deployment,
+ deploymentFlavor.getId());
compositionEntityValidationData.setEntityName(deployment.getDeploymentFlavorCompositionData().getModel());
ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
- .getInvalidComponentComputeAssociationErrorBuilder(
- deploymentlocalFlavor.getModel());
+ .getInvalidComponentComputeAssociationErrorBuilder(deploymentlocalFlavor.getModel());
errorCodeList.add(deploymentFlavorErrorBuilder);
}
@@ -338,15 +309,12 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
components.forEach(component -> {
validateImage(vspId, version, validationData, component);
validateNic(vspId, version, validationData, component);
-
});
}
-
return validationData;
}
- private void validateNic(String vspId, Version version, Set<CompositionEntityValidationData> validationData,
- ComponentEntity component) {
+ private void validateNic(String vspId, Version version, Set<CompositionEntityValidationData> validationData, ComponentEntity component) {
Collection<NicEntity> nics = nicDao.list(new NicEntity(vspId, version, component.getId(), null));
if (CollectionUtils.isNotEmpty(nics)) {
nics.forEach(nicEntity -> {
@@ -354,11 +322,10 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
NetworkType networkType = nic.getNicCompositionData().getNetworkType();
String networkId = nic.getNicCompositionData().getNetworkId();
if (networkType.equals(NetworkType.Internal) && networkId == null) {
- CompositionEntityValidationData compositionEntityValidationData =
- new CompositionEntityValidationData(CompositionEntityType.nic, nic.getId());
+ CompositionEntityValidationData compositionEntityValidationData = new CompositionEntityValidationData(CompositionEntityType.nic,
+ nic.getId());
compositionEntityValidationData.setEntityName(nic.getNicCompositionData().getName());
- ErrorCode nicInternalNetworkErrorBuilder =
- NicInternalNetworkErrorBuilder.getNicNullNetworkIdInternalNetworkIdErrorBuilder();
+ ErrorCode nicInternalNetworkErrorBuilder = NicInternalNetworkErrorBuilder.getNicNullNetworkIdInternalNetworkIdErrorBuilder();
List<String> errors = new ArrayList<>();
errors.add(nicInternalNetworkErrorBuilder.message());
compositionEntityValidationData.setErrors(errors);
@@ -368,12 +335,11 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
}
- private void validateImage(String vspId, Version version, Set<CompositionEntityValidationData> validationData,
- ComponentEntity component) {
+ private void validateImage(String vspId, Version version, Set<CompositionEntityValidationData> validationData, ComponentEntity component) {
Collection<ImageEntity> images = imageDao.list(new ImageEntity(vspId, version, component.getId(), null));
if (CollectionUtils.isEmpty(images)) {
- CompositionEntityValidationData compositionEntityValidationData =
- new CompositionEntityValidationData(component.getType(), component.getId());
+ CompositionEntityValidationData compositionEntityValidationData = new CompositionEntityValidationData(component.getType(),
+ component.getId());
compositionEntityValidationData.setEntityName(component.getComponentCompositionData().getDisplayName());
ErrorCode vfcMissingImageErrorBuilder = ComponentErrorBuilder.vfcMissingImageErrorBuilder();
List<String> errors = new ArrayList<>();
@@ -385,7 +351,6 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private List<ErrorCode> validateVspFields(VspDetails vspDetails) {
List<ErrorCode> errors = new ArrayList<>();
-
if (vspDetails.getName() == null) {
errors.add(createMissingMandatoryFieldError("name"));
}
@@ -418,52 +383,39 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return errors;
}
- private static ErrorCode createMissingMandatoryFieldError(String fieldName) {
- return new ValidationErrorBuilder("must be supplied", fieldName).build();
- }
-
- private Map<String, List<ErrorMessage>> compile(String vendorSoftwareProductId, Version version,
- ToscaServiceModel serviceModel) {
+ private Map<String, List<ErrorMessage>> compile(String vendorSoftwareProductId, Version version, ToscaServiceModel serviceModel) {
if (isServiceModelMissing(serviceModel)) {
return null;
}
-
enrichedServiceModelDao.deleteAll(vendorSoftwareProductId, version);
-
- EnrichmentManager<ToscaServiceModel> enrichmentManager =
- EnrichmentManagerFactory.getInstance().createInterface();
+ EnrichmentManager<ToscaServiceModel> enrichmentManager = EnrichmentManagerFactory.getInstance().createInterface();
enrichmentManager.init(vendorSoftwareProductId, version);
enrichmentManager.setModel(serviceModel);
Map<String, List<ErrorMessage>> enrichErrors = enrichmentManager.enrich();
-
enrichedServiceModelDao.storeServiceModel(vendorSoftwareProductId, version, enrichmentManager.getModel());
-
return enrichErrors;
}
private Collection<ErrorCode> validateLicensingData(VspDetails vspDetails) {
if (vspDetails.getVendorId() != null) {
- Optional<ErrorCode> errorCode =
- vendorLicenseFacade.validateVendorForUsage(vspDetails.getVendorId(), vspDetails.getVlmVersion());
+ Optional<ErrorCode> errorCode = vendorLicenseFacade.validateVendorForUsage(vspDetails.getVendorId(), vspDetails.getVlmVersion());
if (errorCode.isPresent()) {
return Collections.singleton(errorCode.get());
}
}
-
- if (vspDetails.getVendorId() == null || vspDetails.getVlmVersion() == null
- || vspDetails.getLicenseAgreement() == null || CollectionUtils
- .isEmpty(vspDetails.getFeatureGroups())) {
+ if (vspDetails.getVendorId() == null || vspDetails.getVlmVersion() == null || vspDetails.getLicenseAgreement() == null || CollectionUtils
+ .isEmpty(vspDetails.getFeatureGroups())) {
return Collections.emptyList();
}
- return vendorLicenseFacade.validateLicensingData(vspDetails.getVendorId(), vspDetails.getVlmVersion(),
- vspDetails.getLicenseAgreement(), vspDetails.getFeatureGroups());
+ return vendorLicenseFacade.validateLicensingData(vspDetails.getVendorId(), vspDetails.getVlmVersion(), vspDetails.getLicenseAgreement(),
+ vspDetails.getFeatureGroups());
}
@Override
public VspDetails createVsp(VspDetails vspDetails) {
vspInfoDao.create(vspDetails);
vspInfoDao.updateQuestionnaireData(vspDetails.getId(), vspDetails.getVersion(),
- new JsonSchemaDataGenerator(getVspQuestionnaireSchema(null)).generateData());
+ new JsonSchemaDataGenerator(getVspQuestionnaireSchema(null)).generateData());
return vspDetails;
}
@@ -471,16 +423,15 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
public void updateVsp(VspDetails vspDetails) {
VspDetails retrieved = vspInfoDao.get(vspDetails);
if (retrieved == null) {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder().withMessage(
- String.format("Vsp with id %s and version %s does not exist.", vspDetails.getId(),
- vspDetails.getVersion().getId()))).build());
+ throw new CoreException((new ErrorCode.ErrorCodeBuilder()
+ .withMessage(String.format("Vsp with id %s and version %s does not exist.", vspDetails.getId(), vspDetails.getVersion().getId())))
+ .build());
}
vspDetails.setOnboardingMethod(retrieved.getOnboardingMethod());
-
//If any existing feature group is removed from VSP which is also associated in DF then
+
//update DF to remove feature group associations.
updateDeploymentFlavor(vspDetails);
-
updateUniqueName(retrieved.getName(), vspDetails.getName());
vspInfoDao.update(vspDetails);
}
@@ -489,10 +440,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
final List<String> featureGroups = vspDetails.getFeatureGroups();
if (featureGroups != null) {
final Collection<DeploymentFlavorEntity> deploymentFlavorEntities = deploymentFlavorDao
- .list(new DeploymentFlavorEntity(
- vspDetails.getId(),
- vspDetails.getVersion(),
- null));
+ .list(new DeploymentFlavorEntity(vspDetails.getId(), vspDetails.getVersion(), null));
if (Objects.nonNull(deploymentFlavorEntities)) {
for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
updateDeploymentFlavourEntity(featureGroups, deploymentFlavorEntity);
@@ -501,19 +449,16 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
}
- private void updateDeploymentFlavourEntity(List<String> featureGroups,
- DeploymentFlavorEntity deploymentFlavorEntity) {
+ private void updateDeploymentFlavourEntity(List<String> featureGroups, DeploymentFlavorEntity deploymentFlavorEntity) {
final String featureGroupId = deploymentFlavorEntity.getDeploymentFlavorCompositionData().getFeatureGroupId();
if (!featureGroups.contains(featureGroupId)) {
- DeploymentFlavor deploymentFlavorCompositionData =
- deploymentFlavorEntity.getDeploymentFlavorCompositionData();
+ DeploymentFlavor deploymentFlavorCompositionData = deploymentFlavorEntity.getDeploymentFlavorCompositionData();
deploymentFlavorCompositionData.setFeatureGroupId(null);
deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavorCompositionData);
deploymentFlavorDao.update(deploymentFlavorEntity);
}
}
-
@Override
public VspDetails getVsp(String vspId, Version version) {
return getValidatedVsp(vspId, version);
@@ -543,14 +488,11 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
if (packageInfo == null) {
throw new CoreException(new PackageNotFoundErrorBuilder(vspId, version).build());
}
-
ByteBuffer translatedFileBuffer = packageInfo.getTranslatedFile();
if (translatedFileBuffer == null) {
throw new CoreException(new PackageInvalidErrorBuilder(vspId, version).build());
}
-
File translatedFile = new File(VendorSoftwareProductConstants.VSP_PACKAGE_ZIP);
-
try (FileOutputStream fos = new FileOutputStream(translatedFile)) {
fos.write(translatedFileBuffer.array());
} catch (IOException exception) {
@@ -566,11 +508,9 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
if (contentData == null) {
return new byte[0];
}
-
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- try (final ZipOutputStream zos = new ZipOutputStream(baos);
- ZipInputStream ignored = new ZipInputStream(new ByteArrayInputStream(contentData.array()))) {
+ try (final ZipOutputStream zos = new ZipOutputStream(baos); ZipInputStream ignored = new ZipInputStream(
+ new ByteArrayInputStream(contentData.array()))) {
zos.write(contentData.array());
} catch (IOException exception) {
throw new CoreException(new FileCreationErrorBuilder(vspId).build(), exception);
@@ -585,9 +525,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
@Override
public Optional<FilesDataStructure> getOrchestrationTemplateStructure(String vspId, Version version) {
- Optional<String> jsonFileDataStructure =
- orchestrationTemplateDao.getOrchestrationTemplateStructure(vspId, version);
-
+ Optional<String> jsonFileDataStructure = orchestrationTemplateDao.getOrchestrationTemplateStructure(vspId, version);
if (jsonFileDataStructure.isPresent() && JsonUtil.isValidJson(jsonFileDataStructure.get())) {
return Optional.of(JsonUtil.json2Object(jsonFileDataStructure.get(), FilesDataStructure.class));
} else {
@@ -604,10 +542,9 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
populateVersionsForVlm(vspDetails.getVendorId(), vlmVersion);
}
final PackageInfo packageInfo = createPackageInfo(vspDetails);
-
final ToscaFileOutputServiceCsarImpl toscaServiceTemplateServiceCsar = new ToscaFileOutputServiceCsarImpl();
- final FileContentHandler licenseArtifacts = licenseArtifactsService.createLicenseArtifacts(vspDetails.getId(),
- vspDetails.getVendorId(), vlmVersion, vspDetails.getFeatureGroups());
+ final FileContentHandler licenseArtifacts = licenseArtifactsService
+ .createLicenseArtifacts(vspDetails.getId(), vspDetails.getVendorId(), vlmVersion, vspDetails.getFeatureGroups());
final ETSIService etsiService = new ETSIServiceImpl();
if (etsiService.isSol004WithToscaMetaDirectory(toscaServiceModel.getArtifactFiles())) {
final FileContentHandler handler = toscaServiceModel.getArtifactFiles();
@@ -617,20 +554,18 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
packageInfo.setResourceType(etsiService.getResourceType(manifest).name());
packageInfo.setVendorRelease(etsiService.getHighestCompatibleSpecificationVersion(handler).getOriginalValue());
}
- packageInfo.setTranslatedFile(
- ByteBuffer.wrap(toscaServiceTemplateServiceCsar.createOutputFile(toscaServiceModel, licenseArtifacts)));
-
+ packageInfo.setTranslatedFile(ByteBuffer.wrap(toscaServiceTemplateServiceCsar.createOutputFile(toscaServiceModel, licenseArtifacts)));
packageInfoDao.create(packageInfo);
return packageInfo;
}
void populateVersionsForVlm(String vlmId, Version vlmVersion) {
VersioningManager versioningManager = VersioningManagerFactory.getInstance().createInterface();
- versioningManager.list(vlmId).stream().filter(version -> version.getId().equalsIgnoreCase(vlmVersion.getId()))
- .findAny().ifPresent(version -> {
- vlmVersion.setMinor(version.getMinor());
- vlmVersion.setMajor(version.getMajor());
- });
+ versioningManager.list(vlmId).stream().filter(version -> version.getId().equalsIgnoreCase(vlmVersion.getId())).findAny()
+ .ifPresent(version -> {
+ vlmVersion.setMinor(version.getMinor());
+ vlmVersion.setMajor(version.getMajor());
+ });
}
private PackageInfo createPackageInfo(VspDetails vspDetails) {
@@ -646,14 +581,10 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
@Override
-
public QuestionnaireResponse getVspQuestionnaire(String vspId, Version version) {
VspQuestionnaireEntity retrieved = vspInfoDao.getQuestionnaire(vspId, version);
- VersioningUtil
- .validateEntityExistence(retrieved, new VspQuestionnaireEntity(vspId, version), VspDetails.ENTITY_TYPE);
-
+ VersioningUtil.validateEntityExistence(retrieved, new VspQuestionnaireEntity(vspId, version), VspDetails.ENTITY_TYPE);
String questionnaireData = retrieved.getQuestionnaireData();
-
QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
questionnaireResponse.setData(questionnaireData);
questionnaireResponse.setSchema(getVspQuestionnaireSchema(null));
@@ -665,45 +596,34 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
vspInfoDao.updateQuestionnaireData(vspId, version, questionnaireData);
}
-
- private Map<String, List<ErrorMessage>> validateOrchestrationTemplate(
- OrchestrationTemplateEntity orchestrationTemplate) throws IOException {
-
+ private Map<String, List<ErrorMessage>> validateOrchestrationTemplate(OrchestrationTemplateEntity orchestrationTemplate) throws IOException {
if (isOrchestrationTemplateMissing(orchestrationTemplate)) {
return null;
}
Map<String, List<ErrorMessage>> validationErrors = new HashMap<>();
-
- FileContentHandler fileContentMap = CommonUtil.validateAndUploadFileContent(
- OnboardingTypesEnum.getOnboardingTypesEnum(orchestrationTemplate.getFileSuffix()),
+ FileContentHandler fileContentMap = CommonUtil
+ .validateAndUploadFileContent(OnboardingTypesEnum.getOnboardingTypesEnum(orchestrationTemplate.getFileSuffix()),
orchestrationTemplate.getContentData().array());
-
try (InputStream zipFileManifest = fileContentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) {
addDummyHeatBase(zipFileManifest, fileContentMap);
} catch (Exception e) {
LOGGER.error("Invalid package content", e);
}
-
if (CommonUtil.isFileOriginFromZip(orchestrationTemplate.getFileSuffix())) {
ValidationManager validationManager = ValidationManagerUtil.initValidationManager(fileContentMap);
validationErrors.putAll(validationManager.validate());
}
-
- return MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, validationErrors)) ? null
- : validationErrors;
+ return MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, validationErrors)) ? null : validationErrors;
}
private FileContentHandler addDummyHeatBase(InputStream zipFileManifest, FileContentHandler fileContentMap) {
- ManifestContent manifestContent =
- JsonUtil.json2Object(zipFileManifest, ManifestContent.class);
+ ManifestContent manifestContent = JsonUtil.json2Object(zipFileManifest, ManifestContent.class);
for (FileData fileData : manifestContent.getData()) {
if ((fileData.getFile()).contains("dummy_ignore.yaml")) {
String filePath = new File("").getAbsolutePath() + "/resources";
File envFilePath = new File(filePath + "/base_template.env");
File baseFilePath = new File(filePath + "/base_template.yaml");
- try (
- InputStream envStream = new FileInputStream(envFilePath);
- InputStream baseStream = new FileInputStream(baseFilePath);) {
+ try (InputStream envStream = new FileInputStream(envFilePath); InputStream baseStream = new FileInputStream(baseFilePath);) {
fileContentMap.addFile("base_template_dummy_ignore.env", envStream);
fileContentMap.addFile("base_template_dummy_ignore.yaml", baseStream);
} catch (Exception e) {
@@ -713,44 +633,34 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
return fileContentMap;
}
- private QuestionnaireValidationResult validateQuestionnaire(String vspId, Version version,
- String onboardingMethod) {
+
+ private QuestionnaireValidationResult validateQuestionnaire(String vspId, Version version, String onboardingMethod) {
// The apis of CompositionEntityDataManager used here are stateful!
+
// so, it must be re-created from scratch when it is used!
- CompositionEntityDataManager compositionEntityDataManager =
- CompositionEntityDataManagerFactory.getInstance().createInterface();
+ CompositionEntityDataManager compositionEntityDataManager = CompositionEntityDataManagerFactory.getInstance().createInterface();
compositionEntityDataManager.addEntity(vspInfoDao.getQuestionnaire(vspId, version), null);
-
Collection<NicEntity> nics = nicDao.listByVsp(vspId, version);
-
Map<String, List<String>> nicNamesByComponent = new HashMap<>();
for (NicEntity nicEntity : nics) {
compositionEntityDataManager.addEntity(nicEntity, null);
-
Nic nic = nicEntity.getNicCompositionData();
if (nic != null && nic.getName() != null) {
- List<String> nicNames =
- nicNamesByComponent.computeIfAbsent(nicEntity.getComponentId(), k -> new ArrayList<>());
+ List<String> nicNames = nicNamesByComponent.computeIfAbsent(nicEntity.getComponentId(), k -> new ArrayList<>());
nicNames.add(nic.getName());
}
}
-
Collection<ComponentEntity> components = componentDao.listCompositionAndQuestionnaire(vspId, version);
components.forEach(component -> compositionEntityDataManager.addEntity(component,
- new ComponentQuestionnaireSchemaInput(nicNamesByComponent.get(component.getId()),
- JsonUtil.json2Object(component.getQuestionnaireData(), Map.class), null,
- OnboardingMethod.Manual.name().equals(onboardingMethod))));
-
+ new ComponentQuestionnaireSchemaInput(nicNamesByComponent.get(component.getId()),
+ JsonUtil.json2Object(component.getQuestionnaireData(), Map.class), null, OnboardingMethod.Manual.name().equals(onboardingMethod))));
Collection<ComputeEntity> computes = computeDao.listByVsp(vspId, version);
computes.forEach(compute -> compositionEntityDataManager.addEntity(compute, null));
-
if (OnboardingMethod.Manual.name().equals(onboardingMethod)) {
Collection<ImageEntity> images = imageDao.listByVsp(vspId, version);
images.forEach(image -> compositionEntityDataManager.addEntity(image, null));
}
-
- Map<CompositionEntityId, Collection<String>> errorsByEntityId =
- compositionEntityDataManager.validateEntitiesQuestionnaire();
+ Map<CompositionEntityId, Collection<String>> errorsByEntityId = compositionEntityDataManager.validateEntitiesQuestionnaire();
if (MapUtils.isNotEmpty(errorsByEntityId)) {
compositionEntityDataManager.buildTrees();
compositionEntityDataManager.addErrorsToTrees(errorsByEntityId);
@@ -762,24 +672,18 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
@Override
public File getInformationArtifact(String vspId, Version version) {
VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
-
if (vspDetails == null) {
return null;
}
-
String vspName = vspDetails.getName();
ByteBuffer infoArtifactAsByteBuffer;
File infoArtifactFile;
try {
- infoArtifactAsByteBuffer =
- ByteBuffer.wrap(informationArtifactGenerator.generate(vspId, version).getBytes());
-
- infoArtifactFile =
- new File(String.format(VendorSoftwareProductConstants.INFORMATION_ARTIFACT_NAME, vspName));
+ infoArtifactAsByteBuffer = ByteBuffer.wrap(informationArtifactGenerator.generate(vspId, version).getBytes());
+ infoArtifactFile = new File(String.format(VendorSoftwareProductConstants.INFORMATION_ARTIFACT_NAME, vspName));
try (OutputStream out = new BufferedOutputStream(new FileOutputStream(infoArtifactFile))) {
out.write(infoArtifactAsByteBuffer.array());
}
-
} catch (IOException ex) {
throw new CoreException(new InformationArtifactCreationErrorBuilder(vspId).build(), ex);
}
@@ -792,25 +696,19 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
@Override
public Optional<Pair<String, byte[]>> get(String vspId, Version version) throws IOException {
-
OrchestrationTemplateEntity orchestrationTemplateEntity = orchestrationTemplateDao.get(vspId, version);
-
if (isOrchestrationTemplateMissing(orchestrationTemplateEntity)) {
return Optional.empty();
}
-
if (CommonUtil.isFileOriginFromZip(orchestrationTemplateEntity.getFileSuffix())) {
return Optional.of(new ImmutablePair<>(OnboardingTypesEnum.ZIP.toString(),
- candidateService.getZipData(orchestrationTemplateEntity.getContentData())));
+ candidateService.getZipData(orchestrationTemplateEntity.getContentData())));
}
- return Optional.of(new ImmutablePair<>(orchestrationTemplateEntity.getFileSuffix(),
- orchestrationTemplateEntity.getContentData().array()));
+ return Optional.of(new ImmutablePair<>(orchestrationTemplateEntity.getFileSuffix(), orchestrationTemplateEntity.getContentData().array()));
}
void updateUniqueName(String oldVspName, String newVspName) {
- uniqueValueUtil
- .updateUniqueValue(VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME, oldVspName,
- newVspName);
+ uniqueValueUtil.updateUniqueValue(VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME, oldVspName, newVspName);
}
@Override
@@ -819,8 +717,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
private boolean isOrchestrationTemplateMissing(OrchestrationTemplateEntity orchestrationTemplate) {
- return orchestrationTemplate == null || orchestrationTemplate.getContentData() == null
- || orchestrationTemplate.getFileSuffix() == null || orchestrationTemplate.getFileName() == null;
+ return orchestrationTemplate == null || orchestrationTemplate.getContentData() == null || orchestrationTemplate.getFileSuffix() == null
+ || orchestrationTemplate.getFileName() == null;
}
private boolean isServiceModelMissing(ToscaServiceModel serviceModel) {
@@ -859,8 +757,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return this;
}
- public Builder orchestrationTemplateCandidateManager(
- OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager) {
+ public Builder orchestrationTemplateCandidateManager(OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager) {
this.orchestrationTemplateCandidateManager = orchestrationTemplateCandidateManager;
return this;
}
@@ -880,8 +777,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return this;
}
- public Builder enrichedServiceModel(
- EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao) {
+ public Builder enrichedServiceModel(EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao) {
this.enrichedServiceModelDao = enrichedServiceModelDao;
return this;
}
@@ -948,12 +844,10 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private void registerToVersioning() {
if (serviceModelDao != null) {
- serviceModelDao
- .registerVersioning(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
+ serviceModelDao.registerVersioning(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
}
if (enrichedServiceModelDao != null) {
- enrichedServiceModelDao
- .registerVersioning(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
+ enrichedServiceModelDao.registerVersioning(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
}
}
@@ -961,8 +855,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
VendorSoftwareProductManagerImpl vendorSoftwareProductManager = new VendorSoftwareProductManagerImpl();
vendorSoftwareProductManager.vspMergeDao = this.vspMergeDao;
vendorSoftwareProductManager.orchestrationTemplateDao = this.orchestrationTemplateDao;
- vendorSoftwareProductManager.orchestrationTemplateCandidateManager =
- this.orchestrationTemplateCandidateManager;
+ vendorSoftwareProductManager.orchestrationTemplateCandidateManager = this.orchestrationTemplateCandidateManager;
vendorSoftwareProductManager.vspInfoDao = this.vspInfoDao;
vendorSoftwareProductManager.vendorLicenseFacade = this.vendorLicenseFacade;
vendorSoftwareProductManager.serviceModelDao = this.serviceModelDao;
@@ -983,5 +876,4 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return vendorSoftwareProductManager;
}
}
-
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
index a504f35026..177bd79b30 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.core.dao.UniqueValueDaoFactory;
@@ -38,30 +37,27 @@ import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.InformationArtifactGeneratorFactory;
public class VspManagerFactoryImpl extends VspManagerFactory {
- private static final VendorSoftwareProductManager INSTANCE = new VendorSoftwareProductManagerImpl.Builder()
- .vspMerge(VspMergeDaoFactory.getInstance().createInterface())
- .orchestrationTemplate(OrchestrationTemplateDaoFactory.getInstance().createInterface())
- .orchestrationTemplateCandidateManager(OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface())
- .vspInfo(VendorSoftwareProductInfoDaoFactory.getInstance().createInterface())
- .vendorLicenseFacade(VendorLicenseFacadeFactory.getInstance().createInterface())
- .serviceModel(ServiceModelDaoFactory.getInstance().createInterface())
- .enrichedServiceModel(EnrichedServiceModelDaoFactory.getInstance().createInterface())
- .licenseArtifactsService(VendorLicenseArtifactServiceFactory.getInstance().createInterface())
- .informationArtifactGenerator(InformationArtifactGeneratorFactory.getInstance().createInterface())
- .packageInfo(PackageInfoDaoFactory.getInstance().createInterface())
- .deploymentFlavor(DeploymentFlavorDaoFactory.getInstance().createInterface())
- .component(ComponentDaoFactory.getInstance().createInterface())
- .componentDependencyModel(ComponentDependencyModelDaoFactory.getInstance().createInterface())
- .nic(NicDaoFactory.getInstance().createInterface())
- .compute(ComputeDaoFactory.getInstance().createInterface())
- .image(ImageDaoFactory.getInstance().createInterface())
- .manualVspToscaManager(new ManualVspToscaManagerImpl())
- .uniqueValue(UniqueValueDaoFactory.getInstance().createInterface())
- .candidateService(CandidateServiceFactory.getInstance().createInterface())
- .build();
- @Override
- public VendorSoftwareProductManager createInterface() {
- return INSTANCE;
- }
+ private static final VendorSoftwareProductManager INSTANCE = new VendorSoftwareProductManagerImpl.Builder()
+ .vspMerge(VspMergeDaoFactory.getInstance().createInterface())
+ .orchestrationTemplate(OrchestrationTemplateDaoFactory.getInstance().createInterface())
+ .orchestrationTemplateCandidateManager(OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface())
+ .vspInfo(VendorSoftwareProductInfoDaoFactory.getInstance().createInterface())
+ .vendorLicenseFacade(VendorLicenseFacadeFactory.getInstance().createInterface())
+ .serviceModel(ServiceModelDaoFactory.getInstance().createInterface())
+ .enrichedServiceModel(EnrichedServiceModelDaoFactory.getInstance().createInterface())
+ .licenseArtifactsService(VendorLicenseArtifactServiceFactory.getInstance().createInterface())
+ .informationArtifactGenerator(InformationArtifactGeneratorFactory.getInstance().createInterface())
+ .packageInfo(PackageInfoDaoFactory.getInstance().createInterface())
+ .deploymentFlavor(DeploymentFlavorDaoFactory.getInstance().createInterface()).component(ComponentDaoFactory.getInstance().createInterface())
+ .componentDependencyModel(ComponentDependencyModelDaoFactory.getInstance().createInterface())
+ .nic(NicDaoFactory.getInstance().createInterface()).compute(ComputeDaoFactory.getInstance().createInterface())
+ .image(ImageDaoFactory.getInstance().createInterface()).manualVspToscaManager(new ManualVspToscaManagerImpl())
+ .uniqueValue(UniqueValueDaoFactory.getInstance().createInterface()).candidateService(CandidateServiceFactory.getInstance().createInterface())
+ .build();
+
+ @Override
+ public VendorSoftwareProductManager createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/ManifestAnalyzer.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/ManifestAnalyzer.java
index ecb3ac62ed..e3a82e1602 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/ManifestAnalyzer.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/ManifestAnalyzer.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.onboarding;
import java.util.ArrayList;
@@ -29,11 +28,9 @@ import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
public class ManifestAnalyzer {
- private final ManifestContent manifest;
-
private final static Set<Type> HEAT_TYPES = Collections.singleton(Type.HEAT);
-
private final static Set<Type> HELM_TYPES = Collections.singleton(Type.HELM);
+ private final ManifestContent manifest;
public ManifestAnalyzer(ManifestContent manifest) {
this.manifest = manifest;
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageContentHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageContentHandler.java
index c519802568..056d4e1a55 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageContentHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageContentHandler.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.onboarding;
import java.util.HashMap;
@@ -37,17 +36,12 @@ public class OnboardingPackageContentHandler extends FileContentHandler {
public Map<String, String> getFileAndSignaturePathMap(final Set<String> signatureExtensionSet) {
final Map<String, byte[]> files = getFiles();
final Map<String, String> signedFilePairMap = new HashMap<>();
- files.keySet().stream()
- .filter(filePath -> !signatureExtensionSet.contains(FilenameUtils.getExtension(filePath)))
- .forEach(filePath -> {
- final String filePathWithoutExtension = FilenameUtils.removeExtension(filePath);
- signatureExtensionSet.stream()
- .map(extension -> String.format("%s.%s", filePathWithoutExtension, extension))
- .filter(files::containsKey)
- .forEach(file -> signedFilePairMap.put(filePath, file));
- signedFilePairMap.putIfAbsent(filePath, null);
- });
+ files.keySet().stream().filter(filePath -> !signatureExtensionSet.contains(FilenameUtils.getExtension(filePath))).forEach(filePath -> {
+ final String filePathWithoutExtension = FilenameUtils.removeExtension(filePath);
+ signatureExtensionSet.stream().map(extension -> String.format("%s.%s", filePathWithoutExtension, extension)).filter(files::containsKey)
+ .forEach(file -> signedFilePairMap.put(filePath, file));
+ signedFilePairMap.putIfAbsent(filePath, null);
+ });
return signedFilePairMap;
}
-
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessor.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessor.java
index e863f34696..640a15735f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessor.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessor.java
@@ -17,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.onboarding;
import static org.openecomp.sdc.common.errors.Messages.COULD_NOT_READ_MANIFEST_FILE;
@@ -69,13 +68,12 @@ public class OnboardingPackageProcessor {
private static final Logger LOGGER = LoggerFactory.getLogger(OnboardingPackageProcessor.class);
private static final String CSAR_EXTENSION = "csar";
private static final String ZIP_EXTENSION = "zip";
-
private final String packageFileName;
private final byte[] packageFileContent;
- private FileContentHandler packageContent;
private final Set<ErrorMessage> errorMessages = new HashSet<>();
private final OnboardPackageInfo onboardPackageInfo;
private final CnfPackageValidator cnfPackageValidator;
+ private FileContentHandler packageContent;
public OnboardingPackageProcessor(final String packageFileName, final byte[] packageFileContent) {
this.packageFileName = packageFileName;
@@ -106,7 +104,6 @@ public class OnboardingPackageProcessor {
if (hasNoErrors()) {
final String packageName = FilenameUtils.getBaseName(packageFileName);
final String packageExtension = FilenameUtils.getExtension(packageFileName);
-
if (hasSignedPackageStructure()) {
packageInfo = processSignedPackage(packageName, packageExtension);
} else {
@@ -122,8 +119,7 @@ public class OnboardingPackageProcessor {
private void validateFile() {
if (!hasValidExtension()) {
- String message = PACKAGE_INVALID_EXTENSION
- .formatMessage(packageFileName, String.join(", ", CSAR_EXTENSION, ZIP_EXTENSION));
+ String message = PACKAGE_INVALID_EXTENSION.formatMessage(packageFileName, String.join(", ", CSAR_EXTENSION, ZIP_EXTENSION));
reportError(ErrorLevel.ERROR, message);
} else {
try {
@@ -141,8 +137,8 @@ public class OnboardingPackageProcessor {
}
private OnboardPackageInfo processCsarPackage(String packageName, String packageExtension) {
- OnboardPackage onboardPackage = new OnboardPackage(packageName, packageExtension,
- ByteBuffer.wrap(packageFileContent), new OnboardingPackageContentHandler(packageContent));
+ OnboardPackage onboardPackage = new OnboardPackage(packageName, packageExtension, ByteBuffer.wrap(packageFileContent),
+ new OnboardingPackageContentHandler(packageContent));
return new OnboardPackageInfo(onboardPackage, OnboardingTypesEnum.CSAR);
}
@@ -151,15 +147,14 @@ public class OnboardingPackageProcessor {
if (manifest != null) {
List<String> errors = validateZipPackage(manifest);
if (errors.isEmpty()) {
- final OnboardPackage onboardPackage = new OnboardPackage(packageName, packageExtension,
- ByteBuffer.wrap(packageFileContent), packageContent);
+ final OnboardPackage onboardPackage = new OnboardPackage(packageName, packageExtension, ByteBuffer.wrap(packageFileContent),
+ packageContent);
return new OnboardPackageInfo(onboardPackage, OnboardingTypesEnum.ZIP);
} else {
errors.forEach(message -> reportError(ErrorLevel.ERROR, message));
}
} else {
- reportError(ErrorLevel.ERROR,
- COULD_NOT_READ_MANIFEST_FILE.formatMessage(SdcCommon.MANIFEST_NAME, packageFileName));
+ reportError(ErrorLevel.ERROR, COULD_NOT_READ_MANIFEST_FILE.formatMessage(SdcCommon.MANIFEST_NAME, packageFileName));
}
return null;
}
@@ -184,7 +179,6 @@ public class OnboardingPackageProcessor {
ManifestContent manifest = null;
try (InputStream zipFileManifest = packageContent.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) {
manifest = JsonUtil.json2Object(zipFileManifest, ManifestContent.class);
-
} catch (Exception e) {
final String message = COULD_NOT_READ_MANIFEST_FILE.formatMessage(SdcCommon.MANIFEST_NAME, packageFileName);
LOGGER.error(message, e);
@@ -198,8 +192,7 @@ public class OnboardingPackageProcessor {
try {
boolean heatBase = false;
for (FileData fileData : manifestContent.getData()) {
- if (Objects.nonNull(fileData.getType()) &&
- fileData.getType().equals(FileData.Type.HELM) && fileData.getBase()) {
+ if (Objects.nonNull(fileData.getType()) && fileData.getType().equals(FileData.Type.HELM) && fileData.getBase()) {
heatBase = true;
fileData.setBase(false);
FileData dummyHeat = new FileData();
@@ -217,8 +210,7 @@ public class OnboardingPackageProcessor {
String filePath = new File("").getAbsolutePath() + "/resources";
File envFilePath = new File(filePath + "/base_template.env");
File baseFilePath = new File(filePath + "/base_template.yaml");
- try (InputStream envStream = new FileInputStream(envFilePath);
- InputStream baseStream = new FileInputStream(baseFilePath)) {
+ try (InputStream envStream = new FileInputStream(envFilePath); InputStream baseStream = new FileInputStream(baseFilePath)) {
packageContent.addFile("base_template_dummy_ignore.env", envStream);
packageContent.addFile("base_template_dummy_ignore.yaml", baseStream);
} catch (Exception e) {
@@ -252,27 +244,23 @@ public class OnboardingPackageProcessor {
}
final String signatureFilePath = findSignatureFilePath().orElse(null);
final String certificateFilePath = findCertificateFilePath().orElse(null);
- final OnboardSignedPackage onboardSignedPackage =
- new OnboardSignedPackage(packageName, packageExtension, ByteBuffer.wrap(packageFileContent),
- packageContent, signatureFilePath, internalPackagePath, certificateFilePath);
-
+ final OnboardSignedPackage onboardSignedPackage = new OnboardSignedPackage(packageName, packageExtension, ByteBuffer.wrap(packageFileContent),
+ packageContent, signatureFilePath, internalPackagePath, certificateFilePath);
final String internalPackageName = FilenameUtils.getName(internalPackagePath);
final String internalPackageBaseName = FilenameUtils.getBaseName(internalPackagePath);
final String internalPackageExtension = FilenameUtils.getExtension(internalPackagePath);
final byte[] internalPackageContent = packageContent.getFileContent(internalPackagePath);
final OnboardPackage onboardPackage;
try {
- final OnboardingPackageContentHandler fileContentHandler =
- new OnboardingPackageContentHandler(CommonUtil.getZipContent(internalPackageContent));
- onboardPackage = new OnboardPackage(internalPackageBaseName, internalPackageExtension,
- internalPackageContent, fileContentHandler);
+ final OnboardingPackageContentHandler fileContentHandler = new OnboardingPackageContentHandler(
+ CommonUtil.getZipContent(internalPackageContent));
+ onboardPackage = new OnboardPackage(internalPackageBaseName, internalPackageExtension, internalPackageContent, fileContentHandler);
} catch (final ZipException e) {
final String message = PACKAGE_PROCESS_INTERNAL_PACKAGE_ERROR.formatMessage(internalPackageName);
LOGGER.error(message, e);
reportError(ErrorLevel.ERROR, message);
return null;
}
-
return new OnboardPackageInfo(onboardSignedPackage, onboardPackage, OnboardingTypesEnum.SIGNED_CSAR);
}
@@ -281,13 +269,10 @@ public class OnboardingPackageProcessor {
}
private Optional<String> findInternalPackagePath() {
- return packageContent.getFileList().stream()
- .filter(filePath -> {
- final String extension = FilenameUtils.getExtension(filePath);
- return CSAR_EXTENSION.equalsIgnoreCase(extension) || ZIP_EXTENSION.equalsIgnoreCase(extension);
- }
- )
- .findFirst();
+ return packageContent.getFileList().stream().filter(filePath -> {
+ final String extension = FilenameUtils.getExtension(filePath);
+ return CSAR_EXTENSION.equalsIgnoreCase(extension) || ZIP_EXTENSION.equalsIgnoreCase(extension);
+ }).findFirst();
}
private boolean isPackageEmpty() {
@@ -295,60 +280,43 @@ public class OnboardingPackageProcessor {
}
private boolean hasSignedPackageStructure() {
- if (MapUtils.isEmpty(packageContent.getFiles()) || !CollectionUtils.isEmpty(
- packageContent.getFolderList())) {
+ if (MapUtils.isEmpty(packageContent.getFiles()) || !CollectionUtils.isEmpty(packageContent.getFolderList())) {
return false;
}
final int numberOfFiles = packageContent.getFileList().size();
if (numberOfFiles == 2) {
- return hasOneInternalPackageFile(packageContent) &&
- hasOneSignatureFile(packageContent);
+ return hasOneInternalPackageFile(packageContent) && hasOneSignatureFile(packageContent);
}
-
if (numberOfFiles == 3) {
- return hasOneInternalPackageFile(packageContent) &&
- hasOneSignatureFile(packageContent) &&
- hasOneCertificateFile(packageContent);
+ return hasOneInternalPackageFile(packageContent) && hasOneSignatureFile(packageContent) && hasOneCertificateFile(packageContent);
}
-
return false;
}
private boolean hasOneInternalPackageFile(final FileContentHandler fileContentHandler) {
- return fileContentHandler.getFileList().parallelStream()
- .map(FilenameUtils::getExtension)
- .map(String::toLowerCase)
+ return fileContentHandler.getFileList().parallelStream().map(FilenameUtils::getExtension).map(String::toLowerCase)
.filter(file -> file.endsWith(CSAR_EXTENSION)).count() == 1;
}
private boolean hasOneSignatureFile(final FileContentHandler fileContentHandler) {
- return fileContentHandler.getFileList().parallelStream()
- .map(FilenameUtils::getExtension)
- .map(String::toLowerCase)
+ return fileContentHandler.getFileList().parallelStream().map(FilenameUtils::getExtension).map(String::toLowerCase)
.filter(ALLOWED_SIGNATURE_EXTENSIONS::contains).count() == 1;
}
private boolean hasOneCertificateFile(final FileContentHandler fileContentHandler) {
- return fileContentHandler.getFileList().parallelStream()
- .map(FilenameUtils::getExtension)
- .map(String::toLowerCase)
+ return fileContentHandler.getFileList().parallelStream().map(FilenameUtils::getExtension).map(String::toLowerCase)
.filter(ALLOWED_CERTIFICATE_EXTENSIONS::contains).count() == 1;
}
private Optional<String> findSignatureFilePath() {
final Map<String, byte[]> files = packageContent.getFiles();
- return files.keySet().stream()
- .filter(
- fileName -> ALLOWED_SIGNATURE_EXTENSIONS.contains(FilenameUtils.getExtension(fileName).toLowerCase()))
+ return files.keySet().stream().filter(fileName -> ALLOWED_SIGNATURE_EXTENSIONS.contains(FilenameUtils.getExtension(fileName).toLowerCase()))
.findFirst();
}
private Optional<String> findCertificateFilePath() {
final Map<String, byte[]> files = packageContent.getFiles();
- return files.keySet().stream()
- .filter(
- fileName -> ALLOWED_CERTIFICATE_EXTENSIONS.contains(FilenameUtils.getExtension(fileName).toLowerCase()))
+ return files.keySet().stream().filter(fileName -> ALLOWED_CERTIFICATE_EXTENSIONS.contains(FilenameUtils.getExtension(fileName).toLowerCase()))
.findFirst();
}
-
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/validation/CnfPackageValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/validation/CnfPackageValidator.java
index 8520672cd3..50f1fd8d06 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/validation/CnfPackageValidator.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/validation/CnfPackageValidator.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.onboarding.validation;
import static org.openecomp.sdc.common.errors.Messages.MANIFEST_VALIDATION_HELM_IS_BASE_MISSING;
@@ -32,12 +31,10 @@ public class CnfPackageValidator {
public List<String> validateHelmPackage(List<FileData> modules) {
List<String> messages = Collections.emptyList();
-
if (modules != null && !modules.isEmpty()) {
Stats stats = calculateStats(modules);
messages = createErrorMessages(stats);
}
-
return messages;
}
@@ -55,17 +52,14 @@ public class CnfPackageValidator {
private List<String> createErrorMessages(Stats stats) {
List<String> messages = new ArrayList<>();
-
if (stats.without > 0) {
messages.add(MANIFEST_VALIDATION_HELM_IS_BASE_MISSING.formatMessage(stats.without));
}
-
if (stats.base == 0) {
messages.add(MANIFEST_VALIDATION_HELM_IS_BASE_NOT_SET.getErrorMessage());
} else if (stats.base > 1) {
messages.add(MANIFEST_VALIDATION_HELM_IS_BASE_NOT_UNIQUE.getErrorMessage());
}
-
return messages;
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java
index 68309106cd..6e810eefbd 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration;
import java.io.ByteArrayInputStream;
@@ -35,73 +34,60 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardPackageInfo;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
public abstract class BaseOrchestrationTemplateHandler implements OrchestrationTemplateFileHandler {
- protected static final Logger logger = LoggerFactory.getLogger(BaseOrchestrationTemplateHandler.class);
-
- @Override
- public UploadFileResponse upload(final VspDetails vspDetails,
- final OnboardPackageInfo onboardPackageInfo,
- final CandidateService candidateService) {
- final OnboardPackage onboardPackage = onboardPackageInfo.getOnboardPackage();
- final UploadFileResponse uploadFileResponse = new UploadFileResponse();
- uploadFileResponse.setOnboardingType(getHandlerType());
- if (isFileToUploadEmpty(onboardPackage, uploadFileResponse, candidateService)) {
- return uploadFileResponse;
- }
-
- final byte[] fileContentByteArray = onboardPackage.getFileContent().array();
- if (isInvalidRawZipData(onboardPackage.getFileExtension(),
- uploadFileResponse, fileContentByteArray, candidateService)) {
- return uploadFileResponse;
- }
-
- final UploadFileResponse validateResponse = validate(onboardPackageInfo);
- if (!MapUtils.isEmpty(validateResponse.getErrors())) {
- uploadFileResponse.addStructureErrors(validateResponse.getErrors());
- return uploadFileResponse;
- }
+ protected static final Logger logger = LoggerFactory.getLogger(BaseOrchestrationTemplateHandler.class);
- final UploadFileResponse responseFromUpdate = updateCandidateData(vspDetails, onboardPackageInfo,
- candidateService);
- if (!MapUtils.isEmpty(responseFromUpdate.getErrors())) {
- uploadFileResponse.addStructureErrors(responseFromUpdate.getErrors());
+ @Override
+ public UploadFileResponse upload(final VspDetails vspDetails, final OnboardPackageInfo onboardPackageInfo,
+ final CandidateService candidateService) {
+ final OnboardPackage onboardPackage = onboardPackageInfo.getOnboardPackage();
+ final UploadFileResponse uploadFileResponse = new UploadFileResponse();
+ uploadFileResponse.setOnboardingType(getHandlerType());
+ if (isFileToUploadEmpty(onboardPackage, uploadFileResponse, candidateService)) {
+ return uploadFileResponse;
+ }
+ final byte[] fileContentByteArray = onboardPackage.getFileContent().array();
+ if (isInvalidRawZipData(onboardPackage.getFileExtension(), uploadFileResponse, fileContentByteArray, candidateService)) {
+ return uploadFileResponse;
+ }
+ final UploadFileResponse validateResponse = validate(onboardPackageInfo);
+ if (!MapUtils.isEmpty(validateResponse.getErrors())) {
+ uploadFileResponse.addStructureErrors(validateResponse.getErrors());
+ return uploadFileResponse;
+ }
+ final UploadFileResponse responseFromUpdate = updateCandidateData(vspDetails, onboardPackageInfo, candidateService);
+ if (!MapUtils.isEmpty(responseFromUpdate.getErrors())) {
+ uploadFileResponse.addStructureErrors(responseFromUpdate.getErrors());
+ }
+ return uploadFileResponse;
}
- return uploadFileResponse;
- }
-
- protected abstract UploadFileResponse updateCandidateData(final VspDetails vspDetails,
- final OnboardPackageInfo onboardPackageInfo,
- final CandidateService candidateService);
+ protected abstract UploadFileResponse updateCandidateData(final VspDetails vspDetails, final OnboardPackageInfo onboardPackageInfo,
+ final CandidateService candidateService);
- private boolean isFileToUploadEmpty(final OnboardPackage onboardPackage,
- final UploadFileResponse uploadFileResponse,
- final CandidateService candidateService) {
- final ByteArrayInputStream fileToUpload = new ByteArrayInputStream(
- onboardPackage.getFileContent().array());
- Optional<ErrorMessage> errorMessage =
- candidateService.validateNonEmptyFileToUpload(fileToUpload, onboardPackage.getFileExtension());
- if (errorMessage.isPresent()) {
- uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
- return true;
+ private boolean isFileToUploadEmpty(final OnboardPackage onboardPackage, final UploadFileResponse uploadFileResponse,
+ final CandidateService candidateService) {
+ final ByteArrayInputStream fileToUpload = new ByteArrayInputStream(onboardPackage.getFileContent().array());
+ Optional<ErrorMessage> errorMessage = candidateService.validateNonEmptyFileToUpload(fileToUpload, onboardPackage.getFileExtension());
+ if (errorMessage.isPresent()) {
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
+ return true;
+ }
+ return false;
}
- return false;
- }
- protected boolean isInvalidRawZipData(String fileSuffix,
- UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData,
- CandidateService candidateService) {
- Optional<ErrorMessage> errorMessage;
- errorMessage = candidateService.validateRawZipData(fileSuffix, uploadedFileData);
- if (errorMessage.isPresent()) {
- uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
- return true;
+ protected boolean isInvalidRawZipData(String fileSuffix, UploadFileResponse uploadFileResponse, byte[] uploadedFileData,
+ CandidateService candidateService) {
+ Optional<ErrorMessage> errorMessage;
+ errorMessage = candidateService.validateRawZipData(fileSuffix, uploadedFileData);
+ if (errorMessage.isPresent()) {
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
+ return true;
+ }
+ return false;
}
- return false;
- }
- public abstract UploadFileResponse validate(final OnboardPackageInfo onboardPackageInfo);
+ public abstract UploadFileResponse validate(final OnboardPackageInfo onboardPackageInfo);
- protected abstract OnboardingTypesEnum getHandlerType();
+ protected abstract OnboardingTypesEnum getHandlerType();
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
index 94638a5876..e7367c2a49 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
@@ -1,8 +1,8 @@
/*
* Copyright (c) 2018 AT&T Intellectual Property.
- * Modifications Copyright (c) 2018 Verizon Property.
- * Modifications Copyright (c) 2019 Nordix Foundation.
+ * Modifications Copyright (c) 2018 Verizon Property.
+ * Modifications Copyright (c) 2019 Nordix Foundation.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +17,6 @@
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration;
import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
@@ -43,42 +42,35 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardPackageInfo;
import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardSignedPackage;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
-public class OrchestrationTemplateCSARHandler extends BaseOrchestrationTemplateHandler
- implements OrchestrationTemplateFileHandler {
+public class OrchestrationTemplateCSARHandler extends BaseOrchestrationTemplateHandler implements OrchestrationTemplateFileHandler {
@Override
public UploadFileResponse validate(final OnboardPackageInfo onboardPackageInfo) {
final UploadFileResponse uploadFileResponse = new UploadFileResponse();
if (onboardPackageInfo.getPackageType() == OnboardingTypesEnum.SIGNED_CSAR) {
- final OnboardSignedPackage originalOnboardPackage =
- (OnboardSignedPackage) onboardPackageInfo.getOriginalOnboardPackage();
+ final OnboardSignedPackage originalOnboardPackage = (OnboardSignedPackage) onboardPackageInfo.getOriginalOnboardPackage();
validatePackageSecurity(originalOnboardPackage).ifPresent(packageSignatureResponse -> {
if (packageSignatureResponse.hasErrors()) {
uploadFileResponse.addStructureErrors(packageSignatureResponse.getErrors());
}
});
-
if (uploadFileResponse.hasErrors()) {
return uploadFileResponse;
}
}
final OnboardPackage onboardPackage = onboardPackageInfo.getOnboardPackage();
final FileContentHandler fileContentHandler = onboardPackage.getFileContentHandler();
-
try {
final Validator validator = ValidatorFactory.getValidator(fileContentHandler);
uploadFileResponse.addStructureErrors(validator.validateContent(fileContentHandler));
} catch (IOException exception) {
logger.error(exception.getMessage(), exception);
- uploadFileResponse.addStructureError(
- SdcCommon.UPLOAD_FILE,
- new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_CSAR_FILE.getErrorMessage()));
+ uploadFileResponse
+ .addStructureError(SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_CSAR_FILE.getErrorMessage()));
} catch (CoreException coreException) {
logger.error(coreException.getMessage(), coreException);
- uploadFileResponse.addStructureError(
- SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, coreException.getMessage()));
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, coreException.getMessage()));
}
-
return uploadFileResponse;
}
@@ -87,8 +79,7 @@ public class OrchestrationTemplateCSARHandler extends BaseOrchestrationTemplateH
try {
final CsarSecurityValidator csarSecurityValidator = new CsarSecurityValidator();
if (!csarSecurityValidator.verifyPackageSignature(originalOnboardPackage)) {
- final ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR,
- Messages.FAILED_TO_VERIFY_SIGNATURE.getErrorMessage());
+ final ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR, Messages.FAILED_TO_VERIFY_SIGNATURE.getErrorMessage());
logger.error(errorMessage.getMessage());
uploadFileResponseDto.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage);
return Optional.of(uploadFileResponseDto);
@@ -103,31 +94,24 @@ public class OrchestrationTemplateCSARHandler extends BaseOrchestrationTemplateH
}
@Override
- protected UploadFileResponse updateCandidateData(final VspDetails vspDetails,
- final OnboardPackageInfo onboardPackageInfo,
+ protected UploadFileResponse updateCandidateData(final VspDetails vspDetails, final OnboardPackageInfo onboardPackageInfo,
final CandidateService candidateService) {
final UploadFileResponse uploadFileResponse = new UploadFileResponse();
final OnboardPackage csarPackage = onboardPackageInfo.getOnboardPackage();
final OnboardPackage originalOnboardPackage = onboardPackageInfo.getOriginalOnboardPackage();
try {
candidateService.updateCandidateUploadData(vspDetails.getId(), vspDetails.getVersion(),
- new OrchestrationTemplateCandidateData(csarPackage.getFileContent(),
- "", csarPackage.getFileExtension(),
- csarPackage.getFilename(), originalOnboardPackage.getFilename(),
- originalOnboardPackage.getFileExtension(),
- originalOnboardPackage.getFileContent()));
+ new OrchestrationTemplateCandidateData(csarPackage.getFileContent(), "", csarPackage.getFileExtension(), csarPackage.getFilename(),
+ originalOnboardPackage.getFilename(), originalOnboardPackage.getFileExtension(), originalOnboardPackage.getFileContent()));
} catch (final Exception exception) {
- logger.error(getErrorWithParameters(Messages.FILE_LOAD_CONTENT_ERROR.getErrorMessage(),
- getHandlerType().toString()), exception);
- uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE,
- new ErrorMessage(ErrorLevel.ERROR, exception.getMessage()));
+ logger.error(getErrorWithParameters(Messages.FILE_LOAD_CONTENT_ERROR.getErrorMessage(), getHandlerType().toString()), exception);
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, exception.getMessage()));
}
return uploadFileResponse;
}
- @Override
- protected OnboardingTypesEnum getHandlerType() {
- return OnboardingTypesEnum.CSAR;
- }
-
+ @Override
+ protected OnboardingTypesEnum getHandlerType() {
+ return OnboardingTypesEnum.CSAR;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java
index 2d2f1ae92b..9bd1b2ea22 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
@@ -24,7 +23,5 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
@FunctionalInterface
public interface OrchestrationTemplateFileHandler {
- UploadFileResponse upload(final VspDetails vspDetails,
- final OnboardPackageInfo onboardPackageInfo,
- final CandidateService candidateService);
+ UploadFileResponse upload(final VspDetails vspDetails, final OnboardPackageInfo onboardPackageInfo, final CandidateService candidateService);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java
index 3e54260e8b..65ce2f5397 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration;
import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
@@ -35,44 +34,37 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardPackage;
import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardPackageInfo;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
-public class OrchestrationTemplateZipHandler extends BaseOrchestrationTemplateHandler
- implements OrchestrationTemplateFileHandler {
+public class OrchestrationTemplateZipHandler extends BaseOrchestrationTemplateHandler implements OrchestrationTemplateFileHandler {
@Override
public UploadFileResponse validate(final OnboardPackageInfo onboardPackageInfo) {
final UploadFileResponse uploadFileResponse = new UploadFileResponse();
final OnboardPackage onboardPackage = onboardPackageInfo.getOnboardPackage();
- OrchestrationUtil
- .getFileContentMap(OnboardingTypesEnum.ZIP, uploadFileResponse, onboardPackage.getFileContent().array());
+ OrchestrationUtil.getFileContentMap(OnboardingTypesEnum.ZIP, uploadFileResponse, onboardPackage.getFileContent().array());
return uploadFileResponse;
}
- @Override
- protected UploadFileResponse updateCandidateData(final VspDetails vspDetails,
- final OnboardPackageInfo onboardPackageInfo,
- final CandidateService candidateService) {
- final UploadFileResponse uploadFileResponse = new UploadFileResponse();
- try {
- final OnboardPackage zipPackage = onboardPackageInfo.getOnboardPackage();
- final OrchestrationTemplateCandidateData candidateData =
- new CandidateEntityBuilder(candidateService)
- .buildCandidateEntityFromZip(vspDetails, zipPackage.getFileContent().array(), zipPackage.getFileContentHandler(),
- uploadFileResponse.getErrors());
- candidateData.setFileName(zipPackage.getFilename());
- candidateData.setFileSuffix(zipPackage.getFileExtension());
- candidateService
- .updateCandidateUploadData(vspDetails.getId(), vspDetails.getVersion(), candidateData);
- } catch (final Exception exception) {
- logger.error(getErrorWithParameters(Messages.FILE_LOAD_CONTENT_ERROR.getErrorMessage(),
- getHandlerType().toString()), exception);
- uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE,
- new ErrorMessage(ErrorLevel.ERROR, exception.getMessage()));
+ @Override
+ protected UploadFileResponse updateCandidateData(final VspDetails vspDetails, final OnboardPackageInfo onboardPackageInfo,
+ final CandidateService candidateService) {
+ final UploadFileResponse uploadFileResponse = new UploadFileResponse();
+ try {
+ final OnboardPackage zipPackage = onboardPackageInfo.getOnboardPackage();
+ final OrchestrationTemplateCandidateData candidateData = new CandidateEntityBuilder(candidateService)
+ .buildCandidateEntityFromZip(vspDetails, zipPackage.getFileContent().array(), zipPackage.getFileContentHandler(),
+ uploadFileResponse.getErrors());
+ candidateData.setFileName(zipPackage.getFilename());
+ candidateData.setFileSuffix(zipPackage.getFileExtension());
+ candidateService.updateCandidateUploadData(vspDetails.getId(), vspDetails.getVersion(), candidateData);
+ } catch (final Exception exception) {
+ logger.error(getErrorWithParameters(Messages.FILE_LOAD_CONTENT_ERROR.getErrorMessage(), getHandlerType().toString()), exception);
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, exception.getMessage()));
+ }
+ return uploadFileResponse;
}
- return uploadFileResponse;
- }
- @Override
- protected OnboardingTypesEnum getHandlerType() {
- return OnboardingTypesEnum.ZIP;
- }
+ @Override
+ protected OnboardingTypesEnum getHandlerType() {
+ return OnboardingTypesEnum.ZIP;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java
index 4b2decd412..9c881be75e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java
@@ -13,9 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration;
+import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil.ORCHESTRATION_CONFIG_NAMESPACE;
+import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil.ORCHESTRATION_IMPL_KEY;
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
import org.onap.config.api.Configuration;
import org.onap.config.api.ConfigurationManager;
import org.openecomp.core.utilities.CommonMethods;
@@ -24,35 +29,24 @@ import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
import org.openecomp.sdc.vendorsoftwareproduct.dao.errors.OrchestrationTemplateFileExtensionErrorBuilder;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-
-import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil.ORCHESTRATION_CONFIG_NAMESPACE;
-import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil.ORCHESTRATION_IMPL_KEY;
-
public class OrchestrationUploadFactory {
+
private static final Map<String, ImplementationConfiguration> FILE_HANLDERS;
- private OrchestrationUploadFactory() {
- }
static {
Configuration config = ConfigurationManager.lookup();
- FILE_HANLDERS = new ConcurrentHashMap<>(config.populateMap(ORCHESTRATION_CONFIG_NAMESPACE,
- ORCHESTRATION_IMPL_KEY, ImplementationConfiguration.class));
+ FILE_HANLDERS = new ConcurrentHashMap<>(
+ config.populateMap(ORCHESTRATION_CONFIG_NAMESPACE, ORCHESTRATION_IMPL_KEY, ImplementationConfiguration.class));
+ }
+ private OrchestrationUploadFactory() {
}
- public static OrchestrationTemplateFileHandler createOrchestrationTemplateFileHandler(
- final OnboardingTypesEnum onboardingType) {
+ public static OrchestrationTemplateFileHandler createOrchestrationTemplateFileHandler(final OnboardingTypesEnum onboardingType) {
final ImplementationConfiguration orchestrationTemplateFileHandler = FILE_HANLDERS.get(onboardingType.toString());
-
- if(Objects.isNull(orchestrationTemplateFileHandler)){
- throw new CoreException(new OrchestrationTemplateFileExtensionErrorBuilder
- ().build());
+ if (Objects.isNull(orchestrationTemplateFileHandler)) {
+ throw new CoreException(new OrchestrationTemplateFileExtensionErrorBuilder().build());
}
-
- return CommonMethods.newInstance(orchestrationTemplateFileHandler.getImplementationClass(),
- OrchestrationTemplateFileHandler.class);
+ return CommonMethods.newInstance(orchestrationTemplateFileHandler.getImplementationClass(), OrchestrationTemplateFileHandler.class);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
index ef41262621..bc84e89e74 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
@@ -13,9 +13,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration;
+import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.dao.UniqueValueDaoFactory;
@@ -41,366 +53,290 @@ import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.*;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.*;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.MonitoringUploadDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionDataExtractorFactory;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-import java.util.*;
-import java.util.stream.Collectors;
-
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME;
-
public class OrchestrationUtil {
- private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationUtil.class);
- public static final String ORCHESTRATION_CONFIG_NAMESPACE = "orchestration";
- public static final String ORCHESTRATION_IMPL_KEY = "orchestration_impl";
-
- private final NicDao nicDao;
- private final ComponentArtifactDao componentArtifactDao;
- private final ProcessDao processDao;
- private final OrchestrationTemplateDao orchestrationTemplateDataDao;
- private final ComponentDao componentDao;
- private final ServiceModelDao serviceModelDao;
- private final ComponentDependencyModelDao componentDependencyModelDao;
- private final CompositionEntityDataManager compositionEntityDataManager;
- private final CompositionDataExtractor compositionDataExtractor;
-
- public OrchestrationUtil() {
- this(NicDaoFactory.getInstance().createInterface(),
- MonitoringUploadDaoFactory.getInstance().createInterface(),
- ProcessDaoFactory.getInstance().createInterface(),
- OrchestrationTemplateDaoFactory.getInstance().createInterface(),
- ComponentDaoFactory.getInstance().createInterface(),
- ServiceModelDaoFactory.getInstance().createInterface(),
- ComponentDependencyModelDaoFactory.getInstance().createInterface(),
- CompositionEntityDataManagerFactory.getInstance().createInterface(),
+ public static final String ORCHESTRATION_CONFIG_NAMESPACE = "orchestration";
+ public static final String ORCHESTRATION_IMPL_KEY = "orchestration_impl";
+ private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationUtil.class);
+ private final NicDao nicDao;
+ private final ComponentArtifactDao componentArtifactDao;
+ private final ProcessDao processDao;
+ private final OrchestrationTemplateDao orchestrationTemplateDataDao;
+ private final ComponentDao componentDao;
+ private final ServiceModelDao serviceModelDao;
+ private final ComponentDependencyModelDao componentDependencyModelDao;
+ private final CompositionEntityDataManager compositionEntityDataManager;
+ private final CompositionDataExtractor compositionDataExtractor;
+
+ public OrchestrationUtil() {
+ this(NicDaoFactory.getInstance().createInterface(), MonitoringUploadDaoFactory.getInstance().createInterface(),
+ ProcessDaoFactory.getInstance().createInterface(), OrchestrationTemplateDaoFactory.getInstance().createInterface(),
+ ComponentDaoFactory.getInstance().createInterface(), ServiceModelDaoFactory.getInstance().createInterface(),
+ ComponentDependencyModelDaoFactory.getInstance().createInterface(), CompositionEntityDataManagerFactory.getInstance().createInterface(),
CompositionDataExtractorFactory.getInstance().createInterface());
- }
-
- private OrchestrationUtil(
- NicDao nicDao,
- ComponentArtifactDao componentArtifactDao,
- ProcessDao processDao,
- OrchestrationTemplateDao orchestrationTemplateDataDao,
- ComponentDao componentDao,
- ServiceModelDao serviceModelDao,
- ComponentDependencyModelDao componentDependencyModelDao,
- CompositionEntityDataManager compositionEntityDataManager,
- CompositionDataExtractor compositionDataExtractor) {
- this.nicDao = nicDao;
- this.componentArtifactDao = componentArtifactDao;
- this.processDao = processDao;
- this.orchestrationTemplateDataDao = orchestrationTemplateDataDao;
- this.componentDao = componentDao;
- this.serviceModelDao = serviceModelDao;
- this.componentDependencyModelDao = componentDependencyModelDao;
- this.compositionEntityDataManager = compositionEntityDataManager;
- this.compositionDataExtractor = compositionDataExtractor;
- }
-
- public static Optional<FileContentHandler> getFileContentMap(OnboardingTypesEnum type,
- UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData) {
- FileContentHandler contentMap = null;
- try {
- contentMap = CommonUtil.validateAndUploadFileContent(type, uploadedFileData);
- } catch (IOException exception) {
- uploadFileResponse.addStructureError(
- SdcCommon.UPLOAD_FILE,
- new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
- LOGGER.error("{}\n{}", Messages.INVALID_ZIP_FILE.getErrorMessage(),
- exception.getMessage(), exception);
- } catch (CoreException coreException) {
- uploadFileResponse.addStructureError(
- SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, coreException.getMessage()));
- LOGGER.error(coreException.getMessage(), coreException);
}
- return Optional.ofNullable(contentMap);
- }
-
- public void backupComponentsQuestionnaireBeforeDelete(String vspId, Version version,
- Map<String, String> componentsQustanniare,
- Map<String, Map<String, String>>
- componentNicsQustanniare,
- Map<String, Collection<ComponentMonitoringUploadEntity>>
- componentMibList,
- Map<String, Collection<ProcessEntity>>
- componentProcesses,
- Map<String, ProcessEntity> processArtifact) {
- Collection<ComponentEntity> componentsCompositionAndQuestionnaire =
- componentDao.listCompositionAndQuestionnaire(vspId, version);
- componentsCompositionAndQuestionnaire.forEach(componentEntity -> {
- String componentName = componentEntity.getComponentCompositionData().getName();
- componentsQustanniare.put(componentName, componentEntity.getQuestionnaireData());
- backupMibData(vspId, version, componentEntity, componentName, componentMibList);
- backupProcess(vspId, version, componentEntity.getId(), componentName, componentProcesses,
- processArtifact);
- backupNicsQuestionnaire(vspId, version, componentEntity, componentName,
- componentNicsQustanniare);
- });
- }
-
- private void backupMibData(String vspId, Version version, ComponentEntity componentEntity,
- String componentName,
- Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList) {
- Collection<ComponentMonitoringUploadEntity> componentMib =
- componentArtifactDao.listArtifacts(new
- ComponentMonitoringUploadEntity(vspId, version, componentEntity.getId(),
- null));
- if (CollectionUtils.isNotEmpty(componentMib)) {
- componentMibList.put(componentName, componentMib);
+ private OrchestrationUtil(NicDao nicDao, ComponentArtifactDao componentArtifactDao, ProcessDao processDao,
+ OrchestrationTemplateDao orchestrationTemplateDataDao, ComponentDao componentDao, ServiceModelDao serviceModelDao,
+ ComponentDependencyModelDao componentDependencyModelDao, CompositionEntityDataManager compositionEntityDataManager,
+ CompositionDataExtractor compositionDataExtractor) {
+ this.nicDao = nicDao;
+ this.componentArtifactDao = componentArtifactDao;
+ this.processDao = processDao;
+ this.orchestrationTemplateDataDao = orchestrationTemplateDataDao;
+ this.componentDao = componentDao;
+ this.serviceModelDao = serviceModelDao;
+ this.componentDependencyModelDao = componentDependencyModelDao;
+ this.compositionEntityDataManager = compositionEntityDataManager;
+ this.compositionDataExtractor = compositionDataExtractor;
}
- }
- private void backupProcess(String vspId, Version version, String componentId,
- String componentName, Map<String,
- Collection<ProcessEntity>> processes,
- Map<String, ProcessEntity> processArtifact) {
- Collection<ProcessEntity> processList =
- processDao.list(new ProcessEntity(vspId, version, componentId, null));
- if (!processList.isEmpty()) {
- processes.put(componentName, processList);
- processList.forEach(process -> {
- ProcessEntity artifact = processDao
- .getArtifact(new ProcessEntity(vspId, version, componentId, process.getId()));
- if (artifact.getArtifact() != null) {
- processArtifact.put(process.getId(), artifact);
+ public static Optional<FileContentHandler> getFileContentMap(OnboardingTypesEnum type, UploadFileResponse uploadFileResponse,
+ byte[] uploadedFileData) {
+ FileContentHandler contentMap = null;
+ try {
+ contentMap = CommonUtil.validateAndUploadFileContent(type, uploadedFileData);
+ } catch (IOException exception) {
+ uploadFileResponse
+ .addStructureError(SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
+ LOGGER.error("{}\n{}", Messages.INVALID_ZIP_FILE.getErrorMessage(), exception.getMessage(), exception);
+ } catch (CoreException coreException) {
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, coreException.getMessage()));
+ LOGGER.error(coreException.getMessage(), coreException);
}
- });
+ return Optional.ofNullable(contentMap);
}
- }
- private void backupNicsQuestionnaire(String vspId, Version version,
- ComponentEntity componentEntity,
- String componentName,
- Map<String, Map<String, String>> componentNicsQustanniare) {
- Collection<NicEntity>
- nics = nicDao.list(new NicEntity(vspId, version, componentEntity.getId(), null));
- if (CollectionUtils.isNotEmpty(nics)) {
- Map<String, String> nicsQuestionnaire = new HashMap<>();
- nics.forEach(nicEntity -> {
- NicEntity nicQuestionnaire = nicDao.getQuestionnaireData(vspId, version,
- componentEntity.getId(), nicEntity.getId());
+ public static HeatStructureTree createHeatTree(FileContentHandler fileContentMap, Map<String, List<ErrorMessage>> validationErrors) {
+ HeatTreeManager heatTreeManager = HeatTreeManagerUtil.initHeatTreeManager(fileContentMap);
+ heatTreeManager.createTree();
+ heatTreeManager.addErrors(validationErrors);
+ return heatTreeManager.getTree();
+ }
- nicsQuestionnaire.put(nicEntity.getNicCompositionData().getName(),
- nicQuestionnaire.getQuestionnaireData());
- });
- componentNicsQustanniare.put(componentName, nicsQuestionnaire);
+ public void backupComponentsQuestionnaireBeforeDelete(String vspId, Version version, Map<String, String> componentsQustanniare,
+ Map<String, Map<String, String>> componentNicsQustanniare,
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList,
+ Map<String, Collection<ProcessEntity>> componentProcesses,
+ Map<String, ProcessEntity> processArtifact) {
+ Collection<ComponentEntity> componentsCompositionAndQuestionnaire = componentDao.listCompositionAndQuestionnaire(vspId, version);
+ componentsCompositionAndQuestionnaire.forEach(componentEntity -> {
+ String componentName = componentEntity.getComponentCompositionData().getName();
+ componentsQustanniare.put(componentName, componentEntity.getQuestionnaireData());
+ backupMibData(vspId, version, componentEntity, componentName, componentMibList);
+ backupProcess(vspId, version, componentEntity.getId(), componentName, componentProcesses, processArtifact);
+ backupNicsQuestionnaire(vspId, version, componentEntity, componentName, componentNicsQustanniare);
+ });
}
- }
- public void retainComponentQuestionnaireData(String vspId, Version version,
- Map<String, String> componentsQustanniare,
- Map<String, Map<String, String>>
- componentNicsQustanniare,
- Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList,
- Map<String, Collection<ProcessEntity>> processes,
- Map<String, ProcessEntity> processArtifact) {
- //VSP processes
- restoreProcess(vspId, version, null, null, processes, processArtifact);
- Collection<ComponentEntity> components =
- componentDao.list(new ComponentEntity(vspId, version, null));
- components.forEach(componentEntity -> {
- String componentName = componentEntity.getComponentCompositionData().getName();
- if (componentsQustanniare.containsKey(componentName)) {
- componentDao.updateQuestionnaireData(vspId, version,
- componentEntity.getId(),
- componentsQustanniare.get(componentEntity.getComponentCompositionData()
- .getName()));
- if (componentNicsQustanniare.containsKey(componentName)) {
- restoreComponentNicQuestionnaire(vspId, version, componentName, componentEntity,
- componentNicsQustanniare);
+ private void backupMibData(String vspId, Version version, ComponentEntity componentEntity, String componentName,
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList) {
+ Collection<ComponentMonitoringUploadEntity> componentMib = componentArtifactDao
+ .listArtifacts(new ComponentMonitoringUploadEntity(vspId, version, componentEntity.getId(), null));
+ if (CollectionUtils.isNotEmpty(componentMib)) {
+ componentMibList.put(componentName, componentMib);
}
- //MIB //todo add for VES_EVENTS
- if (componentMibList.containsKey(componentName)) {
- restoreComponentMibData(componentName, componentEntity, componentMibList);
- }
- //VFC processes
- restoreProcess(vspId, version, componentEntity.getId(), componentName, processes,
- processArtifact);
- }
- });
- }
-
- private void restoreComponentNicQuestionnaire(String vspId, Version version,
- String componentName,
- ComponentEntity componentEntity,
- Map<String, Map<String, String>> componentNicsQustanniare) {
- Map<String, String> nicsQustanniare = componentNicsQustanniare.get(componentName);
- Collection<NicEntity> nics =
- nicDao.list(new NicEntity(vspId, version, componentEntity.getId(), null));
- nics.forEach(nicEntity -> {
- if (nicsQustanniare.containsKey(nicEntity.getNicCompositionData().getName())) {
- nicDao.updateQuestionnaireData(vspId, version,
- componentEntity.getId(), nicEntity.getId(),
- nicsQustanniare.get(nicEntity.getNicCompositionData().getName()));
- }
- });
- }
-
- private void restoreComponentMibData(String componentName, ComponentEntity componentEntity,
- Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList) {
- Collection<ComponentMonitoringUploadEntity> mibList = componentMibList.get(componentName);
- mibList.forEach(mib -> {
- mib.setComponentId(componentEntity.getId());
- componentArtifactDao.create(mib);
- });
- }
+ }
- private void restoreProcess(String vspId, Version version, String componentId,
- String componentName,
- Map<String, Collection<ProcessEntity>> processes,
- Map<String, ProcessEntity> processArtifact) {
- if (processes.containsKey(componentName)) {
- Collection<ProcessEntity> processList = processes.get(componentName);
- processList.forEach(process -> {
- process.setComponentId(componentId);
- UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance()
- .createInterface());
- uniqueValueUtil.createUniqueValue(PROCESS_NAME, vspId, version.getId(), componentId,
- process.getName());
- processDao.create(process);
- if (processArtifact.containsKey(process.getId())) {
- ProcessEntity artifact = processArtifact.get(process.getId());
- processDao.uploadArtifact(artifact);
+ private void backupProcess(String vspId, Version version, String componentId, String componentName,
+ Map<String, Collection<ProcessEntity>> processes, Map<String, ProcessEntity> processArtifact) {
+ Collection<ProcessEntity> processList = processDao.list(new ProcessEntity(vspId, version, componentId, null));
+ if (!processList.isEmpty()) {
+ processes.put(componentName, processList);
+ processList.forEach(process -> {
+ ProcessEntity artifact = processDao.getArtifact(new ProcessEntity(vspId, version, componentId, process.getId()));
+ if (artifact.getArtifact() != null) {
+ processArtifact.put(process.getId(), artifact);
+ }
+ });
}
- });
}
- }
- public void deleteUploadDataAndContent(String vspId, Version version) {
- VendorSoftwareProductInfoDaoFactory.getInstance().createInterface()
- .delete(new VspDetails(vspId, version));
- }
+ private void backupNicsQuestionnaire(String vspId, Version version, ComponentEntity componentEntity, String componentName,
+ Map<String, Map<String, String>> componentNicsQustanniare) {
+ Collection<NicEntity> nics = nicDao.list(new NicEntity(vspId, version, componentEntity.getId(), null));
+ if (CollectionUtils.isNotEmpty(nics)) {
+ Map<String, String> nicsQuestionnaire = new HashMap<>();
+ nics.forEach(nicEntity -> {
+ NicEntity nicQuestionnaire = nicDao.getQuestionnaireData(vspId, version, componentEntity.getId(), nicEntity.getId());
+ nicsQuestionnaire.put(nicEntity.getNicCompositionData().getName(), nicQuestionnaire.getQuestionnaireData());
+ });
+ componentNicsQustanniare.put(componentName, nicsQuestionnaire);
+ }
+ }
- public void saveUploadData(VspDetails vspDetails,
- OrchestrationTemplateCandidateData candidateData,
- InputStream uploadedFileData,
- FileContentHandler fileContentMap, HeatStructureTree tree) {
- Map<String, Object> manifestAsMap =
- fileContentMap.containsFile(SdcCommon.MANIFEST_NAME)
- ? (Map<String, Object>) JsonUtil.json2Object(fileContentMap.getFileContentAsStream(
- SdcCommon.MANIFEST_NAME), Map.class)
- : new HashMap<>();
+ public void retainComponentQuestionnaireData(String vspId, Version version, Map<String, String> componentsQustanniare,
+ Map<String, Map<String, String>> componentNicsQustanniare,
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList,
+ Map<String, Collection<ProcessEntity>> processes, Map<String, ProcessEntity> processArtifact) {
+ //VSP processes
+ restoreProcess(vspId, version, null, null, processes, processArtifact);
+ Collection<ComponentEntity> components = componentDao.list(new ComponentEntity(vspId, version, null));
+ components.forEach(componentEntity -> {
+ String componentName = componentEntity.getComponentCompositionData().getName();
+ if (componentsQustanniare.containsKey(componentName)) {
+ componentDao.updateQuestionnaireData(vspId, version, componentEntity.getId(),
+ componentsQustanniare.get(componentEntity.getComponentCompositionData().getName()));
+ if (componentNicsQustanniare.containsKey(componentName)) {
+ restoreComponentNicQuestionnaire(vspId, version, componentName, componentEntity, componentNicsQustanniare);
+ }
+ //MIB //todo add for VES_EVENTS
+ if (componentMibList.containsKey(componentName)) {
+ restoreComponentMibData(componentName, componentEntity, componentMibList);
+ }
+ //VFC processes
+ restoreProcess(vspId, version, componentEntity.getId(), componentName, processes, processArtifact);
+ }
+ });
+ }
- OrchestrationTemplateEntity uploadData = new OrchestrationTemplateEntity();
- uploadData.setFileSuffix(candidateData.getFileSuffix());
- uploadData.setFileName(candidateData.getFileName());
- uploadData.setContentData(ByteBuffer.wrap(FileUtils.toByteArray(uploadedFileData)));
- uploadData.setValidationDataStructure(new ValidationStructureList(tree));
- uploadData.setPackageName(Objects.isNull(manifestAsMap.get("name")) ? null :
- (String) manifestAsMap.get("name"));
- uploadData.setPackageVersion(Objects.isNull(manifestAsMap.get("version")) ? null :
- (String) manifestAsMap.get("version"));
- uploadData.setFilesDataStructure(candidateData.getFilesDataStructure());
- orchestrationTemplateDataDao.update(vspDetails.getId(), vspDetails.getVersion(), uploadData);
+ private void restoreComponentNicQuestionnaire(String vspId, Version version, String componentName, ComponentEntity componentEntity,
+ Map<String, Map<String, String>> componentNicsQustanniare) {
+ Map<String, String> nicsQustanniare = componentNicsQustanniare.get(componentName);
+ Collection<NicEntity> nics = nicDao.list(new NicEntity(vspId, version, componentEntity.getId(), null));
+ nics.forEach(nicEntity -> {
+ if (nicsQustanniare.containsKey(nicEntity.getNicCompositionData().getName())) {
+ nicDao.updateQuestionnaireData(vspId, version, componentEntity.getId(), nicEntity.getId(),
+ nicsQustanniare.get(nicEntity.getNicCompositionData().getName()));
+ }
+ });
+ }
- VspMergeDaoFactory.getInstance().createInterface()
- .updateHint(vspDetails.getId(), vspDetails.getVersion());
- }
+ private void restoreComponentMibData(String componentName, ComponentEntity componentEntity,
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList) {
+ Collection<ComponentMonitoringUploadEntity> mibList = componentMibList.get(componentName);
+ mibList.forEach(mib -> {
+ mib.setComponentId(componentEntity.getId());
+ componentArtifactDao.create(mib);
+ });
+ }
- public void saveServiceModel(String vspId, Version version,
- ToscaServiceModel serviceModelToExtract,
- ToscaServiceModel serviceModelToStore) {
- if (serviceModelToExtract != null) {
- serviceModelDao.storeServiceModel(vspId, version, serviceModelToStore);
- //Extracting the compostion data from the output service model of the first phase of
- // translation
- compositionEntityDataManager.saveCompositionData(vspId, version,
- compositionDataExtractor.extractServiceCompositionData(serviceModelToExtract));
+ private void restoreProcess(String vspId, Version version, String componentId, String componentName,
+ Map<String, Collection<ProcessEntity>> processes, Map<String, ProcessEntity> processArtifact) {
+ if (processes.containsKey(componentName)) {
+ Collection<ProcessEntity> processList = processes.get(componentName);
+ processList.forEach(process -> {
+ process.setComponentId(componentId);
+ UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface());
+ uniqueValueUtil.createUniqueValue(PROCESS_NAME, vspId, version.getId(), componentId, process.getName());
+ processDao.create(process);
+ if (processArtifact.containsKey(process.getId())) {
+ ProcessEntity artifact = processArtifact.get(process.getId());
+ processDao.uploadArtifact(artifact);
+ }
+ });
+ }
}
- }
- public static HeatStructureTree createHeatTree(FileContentHandler fileContentMap,
- Map<String, List<ErrorMessage>> validationErrors) {
- HeatTreeManager heatTreeManager = HeatTreeManagerUtil.initHeatTreeManager(fileContentMap);
- heatTreeManager.createTree();
- heatTreeManager.addErrors(validationErrors);
- return heatTreeManager.getTree();
- }
+ public void deleteUploadDataAndContent(String vspId, Version version) {
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface().delete(new VspDetails(vspId, version));
+ }
- public void updateVspComponentDependencies(String vspId, Version version,
- Map<String, String>
- vspComponentIdNameInfoBeforeProcess,
- Collection<ComponentDependencyModelEntity>
- componentDependenciesBeforeDelete) {
- Map<String, String> updatedVspComponentNameIdInfo = getVspComponentNameIdInfo(vspId, version);
- if (MapUtils.isNotEmpty(updatedVspComponentNameIdInfo)) {
- Set<String> updatedVspComponentNames = updatedVspComponentNameIdInfo.keySet();
- if (CollectionUtils.isNotEmpty(componentDependenciesBeforeDelete)) {
- restoreComponentDependencies(vspId, version, vspComponentIdNameInfoBeforeProcess,
- componentDependenciesBeforeDelete, updatedVspComponentNames,
- updatedVspComponentNameIdInfo);
- }
+ public void saveUploadData(VspDetails vspDetails, OrchestrationTemplateCandidateData candidateData, InputStream uploadedFileData,
+ FileContentHandler fileContentMap, HeatStructureTree tree) {
+ Map<String, Object> manifestAsMap = fileContentMap.containsFile(SdcCommon.MANIFEST_NAME) ? (Map<String, Object>) JsonUtil
+ .json2Object(fileContentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME), Map.class) : new HashMap<>();
+ OrchestrationTemplateEntity uploadData = new OrchestrationTemplateEntity();
+ uploadData.setFileSuffix(candidateData.getFileSuffix());
+ uploadData.setFileName(candidateData.getFileName());
+ uploadData.setContentData(ByteBuffer.wrap(FileUtils.toByteArray(uploadedFileData)));
+ uploadData.setValidationDataStructure(new ValidationStructureList(tree));
+ uploadData.setPackageName(Objects.isNull(manifestAsMap.get("name")) ? null : (String) manifestAsMap.get("name"));
+ uploadData.setPackageVersion(Objects.isNull(manifestAsMap.get("version")) ? null : (String) manifestAsMap.get("version"));
+ uploadData.setFilesDataStructure(candidateData.getFilesDataStructure());
+ orchestrationTemplateDataDao.update(vspDetails.getId(), vspDetails.getVersion(), uploadData);
+ VspMergeDaoFactory.getInstance().createInterface().updateHint(vspDetails.getId(), vspDetails.getVersion());
}
- }
- private void restoreComponentDependencies(String vspId, Version version,
- Map<String, String> vspComponentIdNameInfoBeforeProcess,
- Collection<ComponentDependencyModelEntity>
- componentDependenciesBeforeDelete,
- Set<String> updatedVspComponentNames,
- Map<String, String> updatedVspComponentNameIdInfo) {
- for (ComponentDependencyModelEntity componentDependency : componentDependenciesBeforeDelete) {
- String sourceComponentName = vspComponentIdNameInfoBeforeProcess.get(componentDependency
- .getSourceComponentId());
- String targetComponentName = vspComponentIdNameInfoBeforeProcess.get(componentDependency
- .getTargetComponentId());
- if (updatedVspComponentNames.contains(sourceComponentName)
- && (updatedVspComponentNames.contains(targetComponentName))) {
- ComponentDependencyModelEntity restoredDependency =
- new ComponentDependencyModelEntity(vspId, version, null);
- String newSourceComponentId = updatedVspComponentNameIdInfo.get(sourceComponentName);
- restoredDependency.setSourceComponentId(newSourceComponentId);
- String newTargetComponentId = updatedVspComponentNameIdInfo.get(targetComponentName);
- restoredDependency.setTargetComponentId(newTargetComponentId);
- restoredDependency.setRelation(componentDependency.getRelation());
- componentDependencyModelDao.create(restoredDependency);
- }
+ public void saveServiceModel(String vspId, Version version, ToscaServiceModel serviceModelToExtract, ToscaServiceModel serviceModelToStore) {
+ if (serviceModelToExtract != null) {
+ serviceModelDao.storeServiceModel(vspId, version, serviceModelToStore);
+ //Extracting the compostion data from the output service model of the first phase of
+
+ // translation
+ compositionEntityDataManager
+ .saveCompositionData(vspId, version, compositionDataExtractor.extractServiceCompositionData(serviceModelToExtract));
+ }
}
- }
- public Map<String, String> getVspComponentIdNameInfo(String vspId, Version version) {
- Collection<ComponentEntity> updatedVspComponents =
- componentDao.list(new ComponentEntity(vspId, version, null));
- Map<String, String> vspComponentIdNameMap = new HashMap<>();
- if (CollectionUtils.isNotEmpty(updatedVspComponents)) {
- vspComponentIdNameMap = updatedVspComponents.stream()
- .filter(componentEntity -> componentEntity.getComponentCompositionData() != null)
- .collect(Collectors.toMap(ComponentEntity::getId,
- componentEntity -> componentEntity.getComponentCompositionData().getName()));
+ public void updateVspComponentDependencies(String vspId, Version version, Map<String, String> vspComponentIdNameInfoBeforeProcess,
+ Collection<ComponentDependencyModelEntity> componentDependenciesBeforeDelete) {
+ Map<String, String> updatedVspComponentNameIdInfo = getVspComponentNameIdInfo(vspId, version);
+ if (MapUtils.isNotEmpty(updatedVspComponentNameIdInfo)) {
+ Set<String> updatedVspComponentNames = updatedVspComponentNameIdInfo.keySet();
+ if (CollectionUtils.isNotEmpty(componentDependenciesBeforeDelete)) {
+ restoreComponentDependencies(vspId, version, vspComponentIdNameInfoBeforeProcess, componentDependenciesBeforeDelete,
+ updatedVspComponentNames, updatedVspComponentNameIdInfo);
+ }
+ }
+ }
+ private void restoreComponentDependencies(String vspId, Version version, Map<String, String> vspComponentIdNameInfoBeforeProcess,
+ Collection<ComponentDependencyModelEntity> componentDependenciesBeforeDelete,
+ Set<String> updatedVspComponentNames, Map<String, String> updatedVspComponentNameIdInfo) {
+ for (ComponentDependencyModelEntity componentDependency : componentDependenciesBeforeDelete) {
+ String sourceComponentName = vspComponentIdNameInfoBeforeProcess.get(componentDependency.getSourceComponentId());
+ String targetComponentName = vspComponentIdNameInfoBeforeProcess.get(componentDependency.getTargetComponentId());
+ if (updatedVspComponentNames.contains(sourceComponentName) && (updatedVspComponentNames.contains(targetComponentName))) {
+ ComponentDependencyModelEntity restoredDependency = new ComponentDependencyModelEntity(vspId, version, null);
+ String newSourceComponentId = updatedVspComponentNameIdInfo.get(sourceComponentName);
+ restoredDependency.setSourceComponentId(newSourceComponentId);
+ String newTargetComponentId = updatedVspComponentNameIdInfo.get(targetComponentName);
+ restoredDependency.setTargetComponentId(newTargetComponentId);
+ restoredDependency.setRelation(componentDependency.getRelation());
+ componentDependencyModelDao.create(restoredDependency);
+ }
+ }
}
- return vspComponentIdNameMap;
- }
- public Collection<ComponentDependencyModelEntity> getComponentDependenciesBeforeDelete(String
- vspId, Version version) {
- return componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId,
- version, null));
- }
+ public Map<String, String> getVspComponentIdNameInfo(String vspId, Version version) {
+ Collection<ComponentEntity> updatedVspComponents = componentDao.list(new ComponentEntity(vspId, version, null));
+ Map<String, String> vspComponentIdNameMap = new HashMap<>();
+ if (CollectionUtils.isNotEmpty(updatedVspComponents)) {
+ vspComponentIdNameMap = updatedVspComponents.stream().filter(componentEntity -> componentEntity.getComponentCompositionData() != null)
+ .collect(Collectors.toMap(ComponentEntity::getId, componentEntity -> componentEntity.getComponentCompositionData().getName()));
+ }
+ return vspComponentIdNameMap;
+ }
- private Map<String, String> getVspComponentNameIdInfo(String vspId,
- Version version) {
- Collection<ComponentEntity> updatedVspComponents =
- componentDao.list(new ComponentEntity(vspId, version, null));
- Map<String, String> vspComponentNameIdMap = new HashMap<>();
- if (CollectionUtils.isNotEmpty(updatedVspComponents)) {
- vspComponentNameIdMap = updatedVspComponents.stream()
- .filter(componentEntity -> componentEntity.getComponentCompositionData() != null)
- .collect(Collectors
- .toMap(componentEntity -> componentEntity.getComponentCompositionData().getName(),
- ComponentEntity::getId));
+ public Collection<ComponentDependencyModelEntity> getComponentDependenciesBeforeDelete(String vspId, Version version) {
+ return componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, version, null));
}
- return vspComponentNameIdMap;
- }
+ private Map<String, String> getVspComponentNameIdInfo(String vspId, Version version) {
+ Collection<ComponentEntity> updatedVspComponents = componentDao.list(new ComponentEntity(vspId, version, null));
+ Map<String, String> vspComponentNameIdMap = new HashMap<>();
+ if (CollectionUtils.isNotEmpty(updatedVspComponents)) {
+ vspComponentNameIdMap = updatedVspComponents.stream().filter(componentEntity -> componentEntity.getComponentCompositionData() != null)
+ .collect(Collectors.toMap(componentEntity -> componentEntity.getComponentCompositionData().getName(), ComponentEntity::getId));
+ }
+ return vspComponentNameIdMap;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/CsarSecurityValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/CsarSecurityValidator.java
index 0efe65b3b6..81a17f333b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/CsarSecurityValidator.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/CsarSecurityValidator.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation;
import java.util.Optional;
@@ -55,7 +54,6 @@ public class CsarSecurityValidator {
if (certificateFilePath.isPresent()) {
certificateBytes = fileContentHandler.getFileContent(certificateFilePath.get());
}
-
return securityManager.verifySignedData(signatureBytes, certificateBytes, archiveBytes);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilder.java
index eff1fb31cd..ee708b4176 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilder.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation;
import static org.openecomp.sdc.tosca.csar.ManifestTokenType.ALGORITHM;
@@ -36,19 +35,18 @@ import java.util.TreeMap;
*/
public class ManifestBuilder {
+ private static final String PROPERTY_FORMAT = "%s: %s%n";
+ private static final String SECTION_FORMAT = "%s:%n";
private final Map<String, Map<String, String>> sourceWithPropertiesMap = new TreeMap<>();
private final Map<String, List<String>> nonManoArtifactMap = new TreeMap<>();
private final Map<String, String> metadataMap = new TreeMap<>();
- private static final String PROPERTY_FORMAT = "%s: %s%n";
- private static final String SECTION_FORMAT = "%s:%n";
/**
* Adds a metadata property.
*
- * @param metadataProperty the property name
- * @param value the property value
- * @return
- * a reference to this object.
+ * @param metadataProperty the property name
+ * @param value the property value
+ * @return a reference to this object.
*/
public ManifestBuilder withMetaData(final String metadataProperty, final String value) {
metadataMap.put(metadataProperty, value);
@@ -58,9 +56,8 @@ public class ManifestBuilder {
/**
* Adds a manifest source path.
*
- * @param sourcePath The source path
- * @return
- * a reference to this object.
+ * @param sourcePath The source path
+ * @return a reference to this object.
*/
public ManifestBuilder withSource(final String sourcePath) {
sourceWithPropertiesMap.put(sourcePath, null);
@@ -71,10 +68,9 @@ public class ManifestBuilder {
* Adds a manifest source path with the source sign.
*
* @param sourcePath The source path
- * @param hashAlgorithm The hash algorithm
+ * @param hashAlgorithm The hash algorithm
* @param hash The hash representing the sign
- * @return
- * a reference to this object.
+ * @return a reference to this object.
*/
public ManifestBuilder withSignedSource(final String sourcePath, final String hashAlgorithm, final String hash) {
TreeMap<String, String> sourcePropertiesMap = new TreeMap<>();
@@ -87,10 +83,9 @@ public class ManifestBuilder {
/**
* Adds a non mano artifact.
*
- * @param artifactType the artifact type
- * @param sourcePath the artifact source path
- * @return
- * a reference to this object.
+ * @param artifactType the artifact type
+ * @param sourcePath the artifact source path
+ * @return a reference to this object.
*/
public ManifestBuilder withNonManoArtifact(final String artifactType, final String sourcePath) {
nonManoArtifactMap.putIfAbsent(artifactType, new ArrayList<>());
@@ -98,27 +93,22 @@ public class ManifestBuilder {
return this;
}
-
/**
* Builds the String representing the manifest file.
- * @return
- * The manifest file as String
+ *
+ * @return The manifest file as String
*/
public String build() {
final StringBuilder stringBuilder = new StringBuilder();
-
if (!metadataMap.isEmpty()) {
stringBuilder.append(buildMetadata());
}
-
if (!sourceWithPropertiesMap.isEmpty()) {
stringBuilder.append(buildSource());
}
-
if (!nonManoArtifactMap.isEmpty()) {
stringBuilder.append(buildNonManoArtifact());
}
-
return stringBuilder.toString();
}
@@ -143,7 +133,6 @@ public class ManifestBuilder {
if (algorithm != null) {
stringBuilder.append(String.format(PROPERTY_FORMAT, ALGORITHM.getToken(), algorithm));
}
-
final String hash = propertiesMap.get(HASH.getToken());
if (hash != null) {
stringBuilder.append(String.format(PROPERTY_FORMAT, HASH.getToken(), hash));
@@ -167,5 +156,4 @@ public class ManifestBuilder {
}
return stringBuilder.toString();
}
-
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidator.java
index 0d5aef58ac..486970451f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidator.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ONAPCsarValidator.java
@@ -17,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation;
import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
@@ -51,7 +50,6 @@ import org.openecomp.sdc.tosca.csar.ToscaMetadata;
class ONAPCsarValidator implements Validator {
private static Logger logger = LoggerFactory.getLogger(ONAPCsarValidator.class);
-
private List<ErrorMessage> uploadFileErrors = new ArrayList<>();
@Override
@@ -61,30 +59,26 @@ class ONAPCsarValidator implements Validator {
validateMetadata(contentHandler);
validateNoExtraFiles(contentHandler);
validateFolders(contentHandler.getFolderList());
-
- if(uploadFileErrors == null || uploadFileErrors.isEmpty()){
+ if (uploadFileErrors == null || uploadFileErrors.isEmpty()) {
return errors;
}
errors.put(SdcCommon.UPLOAD_FILE, uploadFileErrors);
return errors;
}
- private void validateMetadata(FileContentHandler contentMap){
+ private void validateMetadata(FileContentHandler contentMap) {
if (!validateTOSCAYamlFileInRootExist(contentMap, MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME)) {
try (InputStream metaFileContent = contentMap.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME)) {
-
ToscaMetadata onboardingToscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(metaFileContent);
String entryDefinitionsPath = onboardingToscaMetadata.getMetaEntries().get(ENTRY_DEFINITIONS.getName());
if (entryDefinitionsPath != null) {
validateFileExist(contentMap, entryDefinitionsPath);
} else {
- uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR,
- Messages.METADATA_NO_ENTRY_DEFINITIONS.getErrorMessage()));
+ uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR, Messages.METADATA_NO_ENTRY_DEFINITIONS.getErrorMessage()));
}
} catch (IOException exception) {
logger.error(exception.getMessage(), exception);
- uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR,
- Messages.FAILED_TO_VALIDATE_METADATA.getErrorMessage()));
+ uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR, Messages.FAILED_TO_VALIDATE_METADATA.getErrorMessage()));
}
} else {
validateFileExist(contentMap, MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME);
@@ -95,40 +89,32 @@ class ONAPCsarValidator implements Validator {
if (!validateFileExist(contentMap, MAIN_SERVICE_TEMPLATE_MF_FILE_NAME)) {
return;
}
-
try (final InputStream fileContent = contentMap.getFileContentAsStream(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME)) {
final Manifest onboardingManifest = new ONAPManifestOnboarding();
onboardingManifest.parse(fileContent);
if (!onboardingManifest.isValid()) {
- onboardingManifest.getErrors()
- .forEach(error -> uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR, error)));
+ onboardingManifest.getErrors().forEach(error -> uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR, error)));
}
} catch (final IOException ex) {
- final String errorMessage =
- Messages.MANIFEST_UNEXPECTED_ERROR.formatMessage(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME, ex.getMessage());
+ final String errorMessage = Messages.MANIFEST_UNEXPECTED_ERROR.formatMessage(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME, ex.getMessage());
uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR, errorMessage));
logger.error(errorMessage, ex);
}
}
private void validateNoExtraFiles(FileContentHandler contentMap) {
- List<String> unwantedFiles = contentMap.getFileList().stream()
- .filter(this::filterFiles).collect(Collectors.toList());
+ List<String> unwantedFiles = contentMap.getFileList().stream().filter(this::filterFiles).collect(Collectors.toList());
if (!unwantedFiles.isEmpty()) {
- unwantedFiles.stream().filter(this::filterFiles).forEach(unwantedFile ->
- uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR,
- getErrorWithParameters(Messages.CSAR_FILES_NOT_ALLOWED.getErrorMessage(), unwantedFile))));
+ unwantedFiles.stream().filter(this::filterFiles).forEach(unwantedFile -> uploadFileErrors
+ .add(new ErrorMessage(ErrorLevel.ERROR, getErrorWithParameters(Messages.CSAR_FILES_NOT_ALLOWED.getErrorMessage(), unwantedFile))));
}
}
private void validateFolders(Set<String> folderList) {
- List<String> filterResult =
- folderList.stream().filter(this::filterFolders).collect(Collectors.toList());
+ List<String> filterResult = folderList.stream().filter(this::filterFolders).collect(Collectors.toList());
if (!filterResult.isEmpty()) {
- folderList.stream().filter(this::filterFolders).forEach(unwantedFolder ->
- uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR,
- getErrorWithParameters(Messages.CSAR_DIRECTORIES_NOT_ALLOWED.getErrorMessage(),
- unwantedFolder))));
+ folderList.stream().filter(this::filterFolders).forEach(unwantedFolder -> uploadFileErrors.add(
+ new ErrorMessage(ErrorLevel.ERROR, getErrorWithParameters(Messages.CSAR_DIRECTORIES_NOT_ALLOWED.getErrorMessage(), unwantedFolder))));
}
}
@@ -146,11 +132,10 @@ class ONAPCsarValidator implements Validator {
}
private boolean validateFileExist(FileContentHandler contentMap, String fileName) {
-
boolean containsFile = contentMap.containsFile(fileName);
if (!containsFile) {
- uploadFileErrors.add(new ErrorMessage(ErrorLevel.ERROR,
- getErrorWithParameters(Messages.CSAR_FILE_NOT_FOUND.getErrorMessage(), fileName)));
+ uploadFileErrors
+ .add(new ErrorMessage(ErrorLevel.ERROR, getErrorWithParameters(Messages.CSAR_FILE_NOT_FOUND.getErrorMessage(), fileName)));
}
return containsFile;
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/PMDictionaryValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/PMDictionaryValidator.java
index 90270c2f7e..77c7347e49 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/PMDictionaryValidator.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/PMDictionaryValidator.java
@@ -30,19 +30,14 @@ import org.onap.validation.yaml.error.YamlDocumentValidationError;
public class PMDictionaryValidator {
public void validate(Stream<byte[]> pmDictionaryFiles, Consumer<String> errorReporter) {
- pmDictionaryFiles
- .map(this::validate)
- .flatMap(Collection::stream)
- .forEach(errorReporter);
+ pmDictionaryFiles.map(this::validate).flatMap(Collection::stream).forEach(errorReporter);
}
private List<String> validate(byte[] fileContent) {
List<String> errors = new ArrayList<>();
try {
List<YamlDocumentValidationError> validationErrors = new YamlContentValidator().validate(fileContent);
- validationErrors.stream()
- .map(this::formatErrorMessage)
- .forEach(errors::add);
+ validationErrors.stream().map(this::formatErrorMessage).forEach(errors::add);
} catch (Exception e) {
errors.add(e.getMessage());
}
@@ -50,9 +45,6 @@ public class PMDictionaryValidator {
}
private String formatErrorMessage(YamlDocumentValidationError error) {
- return String.format("Document number: %d, Path: %s, Message: %s",
- error.getYamlDocumentNumber(),
- error.getPath(),
- error.getMessage());
+ return String.format("Document number: %d, Path: %s, Message: %s", error.getYamlDocumentNumber(), error.getPath(), error.getMessage());
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java
index 22ab4f45a6..d99848ddb8 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java
@@ -19,10 +19,8 @@
* * Modifications copyright (c) 2020 Nokia
* ================================================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation;
-
import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_CNF_HELM;
import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_PM_DICTIONARY;
import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_SW_INFORMATION;
@@ -44,6 +42,7 @@ import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_FILE_VERSIO
import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_FILE_VERSION_1_0;
import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME;
+import com.google.common.collect.ImmutableSet;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -57,8 +56,6 @@ import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-
-import com.google.common.collect.ImmutableSet;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.FilenameUtils;
import org.openecomp.core.impl.ToscaDefinitionImportHandler;
@@ -89,22 +86,21 @@ import org.openecomp.sdc.vendorsoftwareproduct.security.SecurityManagerException
import org.yaml.snakeyaml.Yaml;
/**
- * Validates the contents of the package to ensure it complies with the "CSAR with TOSCA-Metadata directory" structure
- * as defined in ETSI GS NFV-SOL 004 v2.6.1.
+ * Validates the contents of the package to ensure it complies with the "CSAR with TOSCA-Metadata directory" structure as defined in ETSI GS NFV-SOL
+ * 004 v2.6.1.
*/
class SOL004MetaDirectoryValidator implements Validator {
private static final Logger LOGGER = LoggerFactory.getLogger(SOL004MetaDirectoryValidator.class);
-
private static final String MANIFEST_SOURCE = "Source";
private static final String MANIFEST_NON_MANO_SOURCE = "Non-MANO Source";
+ protected final ValidatorUtils validatorUtils = new ValidatorUtils();
private final List<ErrorMessage> errorsByFile = new CopyOnWriteArrayList<>();
private final SecurityManager securityManager;
+ private final InternalFilesFilter internalFilesFilter = new InternalFilesFilter();
private OnboardingPackageContentHandler contentHandler;
private Set<String> folderList;
private ToscaMetadata toscaMetadata;
- private final InternalFilesFilter internalFilesFilter = new InternalFilesFilter();
- protected final ValidatorUtils validatorUtils = new ValidatorUtils();
public SOL004MetaDirectoryValidator() {
securityManager = SecurityManager.getInstance();
@@ -121,7 +117,6 @@ class SOL004MetaDirectoryValidator implements Validator {
this.folderList = contentHandler.getFolderList();
parseToscaMetadata();
verifyMetadataFile();
-
if (packageHasCertificate()) {
verifySignedFiles();
}
@@ -143,9 +138,7 @@ class SOL004MetaDirectoryValidator implements Validator {
*/
private void parseToscaMetadata() {
try {
- toscaMetadata =
- OnboardingToscaMetadata
- .parseToscaMetadataFile(contentHandler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME));
+ toscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(contentHandler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME));
} catch (final IOException e) {
reportError(ErrorLevel.ERROR, Messages.METADATA_PARSER_INTERNAL.getErrorMessage());
LOGGER.error(Messages.METADATA_PARSER_INTERNAL.getErrorMessage(), e.getMessage(), e);
@@ -175,12 +168,11 @@ class SOL004MetaDirectoryValidator implements Validator {
final byte[] fileSignatureBytes = contentHandler.getFileContent(fileSignaturePath);
try {
if (!securityManager.verifySignedData(fileSignatureBytes, packageCert, fileBytes)) {
- reportError(ErrorLevel.ERROR,
- Messages.ARTIFACT_INVALID_SIGNATURE.formatMessage(fileSignaturePath, filePath));
+ reportError(ErrorLevel.ERROR, Messages.ARTIFACT_INVALID_SIGNATURE.formatMessage(fileSignaturePath, filePath));
}
} catch (final SecurityManagerException e) {
final String errorMessage = Messages.ARTIFACT_SIGNATURE_VALIDATION_ERROR
- .formatMessage(fileSignaturePath, filePath, packageCertificatePath, e.getMessage());
+ .formatMessage(fileSignaturePath, filePath, packageCertificatePath, e.getMessage());
reportError(ErrorLevel.ERROR, errorMessage);
LOGGER.error(errorMessage, e);
}
@@ -196,8 +188,7 @@ class SOL004MetaDirectoryValidator implements Validator {
reportError(ErrorLevel.ERROR, Messages.MANIFEST_INVALID_EXT.getErrorMessage());
}
if (!mainDefinitionFileName.equals(manifestFileName)) {
- reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_INVALID_NAME.getErrorMessage(),
- manifestFileName, mainDefinitionFileName));
+ reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_INVALID_NAME.getErrorMessage(), manifestFileName, mainDefinitionFileName));
}
}
@@ -211,15 +202,13 @@ class SOL004MetaDirectoryValidator implements Validator {
private boolean hasETSIMetadata() {
final Map<String, String> entries = toscaMetadata.getMetaEntries();
- return hasEntry(entries, TOSCA_META_FILE_VERSION_ENTRY.getName())
- && hasEntry(entries, CSAR_VERSION_ENTRY.getName())
- && hasEntry(entries, CREATED_BY_ENTRY.getName());
+ return hasEntry(entries, TOSCA_META_FILE_VERSION_ENTRY.getName()) && hasEntry(entries, CSAR_VERSION_ENTRY.getName()) && hasEntry(entries,
+ CREATED_BY_ENTRY.getName());
}
private boolean hasEntry(final Map<String, String> entries, final String mandatoryEntry) {
if (!entries.containsKey(mandatoryEntry)) {
- reportError(ErrorLevel.ERROR,
- String.format(Messages.METADATA_MISSING_ENTRY.getErrorMessage(), mandatoryEntry));
+ reportError(ErrorLevel.ERROR, String.format(Messages.METADATA_MISSING_ENTRY.getErrorMessage(), mandatoryEntry));
return false;
}
return true;
@@ -237,7 +226,6 @@ class SOL004MetaDirectoryValidator implements Validator {
return;
}
final String value = entry.getValue();
-
switch (toscaMetaEntry) {
case TOSCA_META_FILE_VERSION_ENTRY:
case CSAR_VERSION_ENTRY:
@@ -277,18 +265,14 @@ class SOL004MetaDirectoryValidator implements Validator {
validateOtherEntries(value);
} else {
final String key = (String) entry.getKey();
- reportError(ErrorLevel.ERROR,
- String.format(Messages.MANIFEST_INVALID_PNF_METADATA.getErrorMessage(), key));
+ reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_INVALID_PNF_METADATA.getErrorMessage(), key));
}
-
}
}
private void verifyMetadataEntryVersions(final String key, final String version) {
- if (!(isValidTOSCAVersion(key, version) || isValidCSARVersion(key, version)
- || CREATED_BY_ENTRY.getName().equals(key))) {
- errorsByFile.add(new ErrorMessage(ErrorLevel.ERROR,
- String.format(Messages.METADATA_INVALID_VERSION.getErrorMessage(), key, version)));
+ if (!(isValidTOSCAVersion(key, version) || isValidCSARVersion(key, version) || CREATED_BY_ENTRY.getName().equals(key))) {
+ errorsByFile.add(new ErrorMessage(ErrorLevel.ERROR, String.format(Messages.METADATA_INVALID_VERSION.getErrorMessage(), key, version)));
LOGGER.error("{}: key {} - value {} ", Messages.METADATA_INVALID_VERSION.getErrorMessage(), key, version);
}
}
@@ -298,16 +282,13 @@ class SOL004MetaDirectoryValidator implements Validator {
}
private boolean isValidCSARVersion(final String value, final String version) {
- return CSAR_VERSION_ENTRY.getName().equals(value) && (CSAR_VERSION_1_1.equals(version)
- || CSAR_VERSION_1_0.equals(version));
+ return CSAR_VERSION_ENTRY.getName().equals(value) && (CSAR_VERSION_1_1.equals(version) || CSAR_VERSION_1_0.equals(version));
}
protected void validateDefinitionFile(final String filePath) {
final Set<String> existingFiles = contentHandler.getFileList();
-
if (verifyFileExists(existingFiles, filePath)) {
- final ToscaDefinitionImportHandler toscaDefinitionImportHandler =
- new ToscaDefinitionImportHandler(contentHandler.getFiles(), filePath);
+ final ToscaDefinitionImportHandler toscaDefinitionImportHandler = new ToscaDefinitionImportHandler(contentHandler.getFiles(), filePath);
final List<ErrorMessage> validationErrorList = toscaDefinitionImportHandler.getErrors();
if (CollectionUtils.isNotEmpty(validationErrorList)) {
errorsByFile.addAll(validationErrorList);
@@ -345,31 +326,23 @@ class SOL004MetaDirectoryValidator implements Validator {
private void verifyManifestMetadata(final Map<String, String> metadata) {
if (!validMetaLimit(metadata)) {
- reportError(ErrorLevel.ERROR,
- String.format(Messages.MANIFEST_METADATA_DOES_NOT_MATCH_LIMIT.getErrorMessage(),
- MANIFEST_METADATA_LIMIT));
+ reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_METADATA_DOES_NOT_MATCH_LIMIT.getErrorMessage(), MANIFEST_METADATA_LIMIT));
}
handleMetadataEntries(metadata);
}
protected boolean isPnfMetadata(final Map<String, String> metadata) {
final String firstMetadataDefinition = metadata.keySet().iterator().next();
- final String expectedMetadataType =
- firstMetadataDefinition.contains(TOSCA_TYPE_PNF) ? TOSCA_TYPE_PNF : TOSCA_TYPE_VNF;
- if (metadata.keySet().stream()
- .anyMatch((final String metadataEntry) -> !metadataEntry.contains(expectedMetadataType))) {
+ final String expectedMetadataType = firstMetadataDefinition.contains(TOSCA_TYPE_PNF) ? TOSCA_TYPE_PNF : TOSCA_TYPE_VNF;
+ if (metadata.keySet().stream().anyMatch((final String metadataEntry) -> !metadataEntry.contains(expectedMetadataType))) {
throw new InvalidManifestMetadataException(Messages.MANIFEST_METADATA_INVALID_ENTRY.getErrorMessage());
}
-
return TOSCA_TYPE_PNF.equals(expectedMetadataType);
}
private void handleMetadataEntries(final Map<String, String> metadata) {
- getManifestMetadata(metadata).stream()
- .filter(requiredEntry -> !metadata.containsKey(requiredEntry))
- .forEach(requiredEntry ->
- reportError(ErrorLevel.ERROR,
- String.format(Messages.MANIFEST_METADATA_MISSING_ENTRY.getErrorMessage(), requiredEntry)));
+ getManifestMetadata(metadata).stream().filter(requiredEntry -> !metadata.containsKey(requiredEntry)).forEach(
+ requiredEntry -> reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_METADATA_MISSING_ENTRY.getErrorMessage(), requiredEntry)));
}
/**
@@ -381,9 +354,7 @@ class SOL004MetaDirectoryValidator implements Validator {
final Set<String> packageFiles = contentHandler.getFileList();
final List<String> sources = internalFilesFilter.filter(onboardingManifest.getSources());
verifyFilesExist(packageFiles, sources, MANIFEST_SOURCE);
-
final Map<String, List<String>> nonManoArtifacts = onboardingManifest.getNonManoSources();
-
final List<String> nonManoValidFilePaths = new ArrayList<>();
nonManoArtifacts.forEach((nonManoType, files) -> {
final List<String> internalNonManoFileList = internalFilesFilter.filter(files);
@@ -397,9 +368,7 @@ class SOL004MetaDirectoryValidator implements Validator {
validateOnapCnfHelmNonManoEntry(files);
}
});
-
verifyFilesExist(packageFiles, nonManoValidFilePaths, MANIFEST_NON_MANO_SOURCE);
-
final Set<String> allReferredFiles = new HashSet<>();
allReferredFiles.addAll(sources);
allReferredFiles.addAll(nonManoValidFilePaths);
@@ -412,32 +381,25 @@ class SOL004MetaDirectoryValidator implements Validator {
return;
}
if (files.size() != 1) {
- final String formattedFileList = files.stream()
- .map(filePath -> String.format("'%s'", filePath))
- .collect(Collectors.joining(", "));
- reportError(ErrorLevel.ERROR,
- Messages.UNIQUE_SW_INFORMATION_NON_MANO_ERROR.formatMessage(formattedFileList));
+ final String formattedFileList = files.stream().map(filePath -> String.format("'%s'", filePath)).collect(Collectors.joining(", "));
+ reportError(ErrorLevel.ERROR, Messages.UNIQUE_SW_INFORMATION_NON_MANO_ERROR.formatMessage(formattedFileList));
return;
}
final String swInformationFilePath = files.get(0);
final byte[] swInformationYaml = contentHandler.getFileContent(swInformationFilePath);
- final Optional<PnfSoftwareInformation> parsedYaml = SoftwareInformationArtifactYamlParser
- .parse(swInformationYaml);
+ final Optional<PnfSoftwareInformation> parsedYaml = SoftwareInformationArtifactYamlParser.parse(swInformationYaml);
if (!parsedYaml.isPresent()) {
- reportError(ErrorLevel.ERROR,
- Messages.INVALID_SW_INFORMATION_NON_MANO_ERROR.formatMessage(swInformationFilePath));
+ reportError(ErrorLevel.ERROR, Messages.INVALID_SW_INFORMATION_NON_MANO_ERROR.formatMessage(swInformationFilePath));
} else {
final PnfSoftwareInformation pnfSoftwareInformation = parsedYaml.get();
if (!pnfSoftwareInformation.isValid()) {
- reportError(ErrorLevel.ERROR,
- Messages.INCORRECT_SW_INFORMATION_NON_MANO_ERROR.formatMessage(swInformationFilePath));
+ reportError(ErrorLevel.ERROR, Messages.INCORRECT_SW_INFORMATION_NON_MANO_ERROR.formatMessage(swInformationFilePath));
}
}
}
/**
- * Validates if a YAML file has the correct extension, is not empty and the content is a valid YAML. Reports each
- * error found.
+ * Validates if a YAML file has the correct extension, is not empty and the content is a valid YAML. Reports each error found.
*
* @param filePath the file path inside the package
*/
@@ -450,7 +412,6 @@ class SOL004MetaDirectoryValidator implements Validator {
reportError(ErrorLevel.ERROR, Messages.INVALID_YAML_EXTENSION.formatMessage(filePath));
return;
}
-
try (final InputStream fileContent = contentHandler.getFileContentAsStream(filePath)) {
if (fileContent == null) {
reportError(ErrorLevel.ERROR, Messages.EMPTY_YAML_FILE_1.formatMessage(filePath));
@@ -477,8 +438,7 @@ class SOL004MetaDirectoryValidator implements Validator {
private void verifyFilesBeingReferred(final Set<String> referredFileSet, final Set<String> packageFileSet) {
packageFileSet.forEach(filePath -> {
if (!isManifestFile(filePath) && !referredFileSet.contains(filePath)) {
- reportError(ErrorLevel.ERROR,
- String.format(Messages.MISSING_MANIFEST_REFERENCE.getErrorMessage(), filePath));
+ reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_MANIFEST_REFERENCE.getErrorMessage(), filePath));
}
});
}
@@ -489,16 +449,14 @@ class SOL004MetaDirectoryValidator implements Validator {
private void validateOtherEntries(final String folderPath) {
if (!verifyFoldersExist(folderList, folderPath)) {
- reportError(ErrorLevel.ERROR, String.format(Messages.METADATA_MISSING_OPTIONAL_FOLDERS.getErrorMessage(),
- folderPath));
+ reportError(ErrorLevel.ERROR, String.format(Messages.METADATA_MISSING_OPTIONAL_FOLDERS.getErrorMessage(), folderPath));
}
}
private void validateCertificate(final String file) {
final Set<String> packageFiles = contentHandler.getFileList();
if (!verifyFileExist(packageFiles, file)) {
- reportError(ErrorLevel.ERROR,
- String.format(Messages.MISSING_METADATA_FILES.getErrorMessage(), file, file));
+ reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_METADATA_FILES.getErrorMessage(), file, file));
}
}
@@ -509,8 +467,7 @@ class SOL004MetaDirectoryValidator implements Validator {
private void verifyFilesExist(final Set<String> existingFiles, final List<String> sources, final String type) {
sources.forEach(file -> {
if (!existingFiles.contains(file)) {
- reportError(ErrorLevel.ERROR,
- String.format(Messages.MISSING_MANIFEST_SOURCE.getErrorMessage(), type, file));
+ reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_MANIFEST_SOURCE.getErrorMessage(), type, file));
}
});
}
@@ -552,10 +509,8 @@ class SOL004MetaDirectoryValidator implements Validator {
}
private void validatePmDictionaryContentsAgainstSchema() {
- final Stream<byte[]> pmDictionaryFiles = new FileExtractor(getEtsiEntryManifestPath(), contentHandler)
- .findFiles(ONAP_PM_DICTIONARY);
- new PMDictionaryValidator()
- .validate(pmDictionaryFiles, (String message) -> reportError(ErrorLevel.ERROR, message));
+ final Stream<byte[]> pmDictionaryFiles = new FileExtractor(getEtsiEntryManifestPath(), contentHandler).findFiles(ONAP_PM_DICTIONARY);
+ new PMDictionaryValidator().validate(pmDictionaryFiles, (String message) -> reportError(ErrorLevel.ERROR, message));
}
private String getEtsiEntryManifestPath() {
@@ -564,6 +519,7 @@ class SOL004MetaDirectoryValidator implements Validator {
/**
* Validates if onap_cnf_helm non_mano type points to a file
+ *
* @param files
*/
private void validateOnapCnfHelmNonManoEntry(final List<String> files) {
@@ -572,11 +528,8 @@ class SOL004MetaDirectoryValidator implements Validator {
return;
}
if (files.size() != 1) {
- final String formattedFileList = files.stream()
- .map(filePath -> String.format("'%s'", filePath))
- .collect(Collectors.joining(", "));
- reportError(ErrorLevel.ERROR,
- Messages.UNIQUE_ONAP_CNF_HELM_NON_MANO_ERROR.formatMessage(formattedFileList));
+ final String formattedFileList = files.stream().map(filePath -> String.format("'%s'", filePath)).collect(Collectors.joining(", "));
+ reportError(ErrorLevel.ERROR, Messages.UNIQUE_ONAP_CNF_HELM_NON_MANO_ERROR.formatMessage(formattedFileList));
}
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version3MetaDirectoryValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version3MetaDirectoryValidator.java
index 9e380a355c..12d5ecfff9 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version3MetaDirectoryValidator.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version3MetaDirectoryValidator.java
@@ -36,8 +36,8 @@ import org.openecomp.sdc.tosca.csar.ToscaMetaEntry;
import org.openecomp.sdc.vendorsoftwareproduct.security.SecurityManager;
/**
- * Validates the contents of the package to ensure it complies with the "CSAR with TOSCA-Metadata directory" structure
- * as defined in ETSI GS NFV-SOL 004 v3.3.1.
+ * Validates the contents of the package to ensure it complies with the "CSAR with TOSCA-Metadata directory" structure as defined in ETSI GS NFV-SOL
+ * 004 v3.3.1.
*/
class SOL004Version3MetaDirectoryValidator extends SOL004MetaDirectoryValidator {
@@ -56,8 +56,9 @@ class SOL004Version3MetaDirectoryValidator extends SOL004MetaDirectoryValidator
if (!ToscaMetaEntry.OTHER_DEFINITIONS.getName().equals(entry.getKey())) {
reportError(ErrorLevel.ERROR, Messages.METADATA_UNSUPPORTED_ENTRY.formatMessage(entry.getKey()));
LOGGER.warn(Messages.METADATA_UNSUPPORTED_ENTRY.getErrorMessage(), entry.getKey());
- } else
+ } else {
validateDefinitionFile(entry.getValue());
+ }
}
@Override
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version4MetaDirectoryValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version4MetaDirectoryValidator.java
index 701abfc677..31c19d7794 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version4MetaDirectoryValidator.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004Version4MetaDirectoryValidator.java
@@ -36,8 +36,8 @@ import org.openecomp.sdc.tosca.csar.ToscaMetaEntry;
import org.openecomp.sdc.vendorsoftwareproduct.security.SecurityManager;
/**
- * Validates the contents of the package to ensure it complies with the "CSAR with TOSCA-Metadata directory" structure
- * as defined in ETSI GS NFV-SOL 004 v3.3.1 with CNF Enhancements from ETSI GS NFV-SOL 004 v4.1.1
+ * Validates the contents of the package to ensure it complies with the "CSAR with TOSCA-Metadata directory" structure as defined in ETSI GS NFV-SOL
+ * 004 v3.3.1 with CNF Enhancements from ETSI GS NFV-SOL 004 v4.1.1
*/
class SOL004Version4MetaDirectoryValidator extends SOL004MetaDirectoryValidator {
@@ -78,5 +78,4 @@ class SOL004Version4MetaDirectoryValidator extends SOL004MetaDirectoryValidator
validateDefinitionFile(entry.getValue());
}
}
-
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/Validator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/Validator.java
index 34386b6d29..e8f88c7eba 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/Validator.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/Validator.java
@@ -17,22 +17,19 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation;
-import org.openecomp.core.utilities.file.FileContentHandler;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
import java.util.List;
import java.util.Map;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
/**
* Validates the contents of the CSAR package uploaded in SDC.
*/
-
public interface Validator {
/**
- *
* @param contentHandler contains file and its data
* @return errors Map of errors that occur
*/
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactory.java
index 9d218190d8..27a1852644 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactory.java
@@ -17,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation;
import static org.openecomp.sdc.tosca.csar.CSARConstants.ETSI_VERSION_2_7_1;
@@ -29,8 +28,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi.ETSIServiceImp
public class ValidatorFactory {
- private ValidatorFactory(){
-
+ private ValidatorFactory() {
}
/**
@@ -45,7 +43,7 @@ public class ValidatorFactory {
if (!etsiService.isSol004WithToscaMetaDirectory(fileContentHandler)) {
return new ONAPCsarValidator();
}
- if (!etsiService.getHighestCompatibleSpecificationVersion(fileContentHandler).isLowerThan(ETSI_VERSION_2_7_1)){
+ if (!etsiService.getHighestCompatibleSpecificationVersion(fileContentHandler).isLowerThan(ETSI_VERSION_2_7_1)) {
if (etsiService.hasCnfEnhancements(fileContentHandler)) {
return new SOL004Version4MetaDirectoryValidator();
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/exception/MissingCertificateException.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/exception/MissingCertificateException.java
index 620ff345ad..e3d91e01df 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/exception/MissingCertificateException.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/exception/MissingCertificateException.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.exception;
public class MissingCertificateException extends RuntimeException {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/FileExtractor.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/FileExtractor.java
index c6d7d637fa..bfef0b4471 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/FileExtractor.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/FileExtractor.java
@@ -48,8 +48,7 @@ public class FileExtractor {
Map<String, List<String>> nonManoSources = extractNonManoSources();
List<String> pathsToSources = nonManoSources.getOrDefault(fileType.getType(), new ArrayList<>());
List<String> pathsToLocalFiles = internalFilesFilter.filter(pathsToSources);
- return pathsToLocalFiles.stream()
- .map(contentHandler::getFileContent);
+ return pathsToLocalFiles.stream().map(contentHandler::getFileContent);
}
private Map<String, List<String>> extractNonManoSources() {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/InternalFilesFilter.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/InternalFilesFilter.java
index 50dcd0ce29..ce119f6a6f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/InternalFilesFilter.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/InternalFilesFilter.java
@@ -25,9 +25,7 @@ import java.util.stream.Collectors;
public class InternalFilesFilter {
public List<String> filter(final List<String> sources) {
- return sources.stream()
- .filter(this::isInternalFile)
- .collect(Collectors.toList());
+ return sources.stream().filter(this::isInternalFile).collect(Collectors.toList());
}
private boolean isInternalFile(final String filePath) {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/ValidatorUtils.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/ValidatorUtils.java
index cfdd53774f..d260b1272b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/ValidatorUtils.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/utils/ValidatorUtils.java
@@ -17,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.utils;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_TYPE_PNF;
@@ -32,15 +31,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.exceptions.Inv
public class ValidatorUtils {
public boolean isPnfMetadata(List<String> keys) {
- keys = keys.stream().filter(key -> !COMPATIBLE_SPECIFICATION_VERSIONS.getToken().equals(key))
- .collect(Collectors.toList());
- final String expectedMetadataType =
- keys.get(0).contains(TOSCA_TYPE_PNF) ? TOSCA_TYPE_PNF : TOSCA_TYPE_VNF;
- if (keys.stream()
- .anyMatch(k -> !k.startsWith(expectedMetadataType))) {
+ keys = keys.stream().filter(key -> !COMPATIBLE_SPECIFICATION_VERSIONS.getToken().equals(key)).collect(Collectors.toList());
+ final String expectedMetadataType = keys.get(0).contains(TOSCA_TYPE_PNF) ? TOSCA_TYPE_PNF : TOSCA_TYPE_VNF;
+ if (keys.stream().anyMatch(k -> !k.startsWith(expectedMetadataType))) {
throw new InvalidManifestMetadataException(Messages.MANIFEST_METADATA_INVALID_ENTRY.getErrorMessage());
}
return expectedMetadataType.equals(TOSCA_TYPE_PNF);
}
-
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/exceptions/InvalidManifestMetadataException.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/exceptions/InvalidManifestMetadataException.java
index 137891c0c9..1204a73509 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/exceptions/InvalidManifestMetadataException.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/exceptions/InvalidManifestMetadataException.java
@@ -17,12 +17,11 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.exceptions;
-public class InvalidManifestMetadataException extends RuntimeException{
+public class InvalidManifestMetadataException extends RuntimeException {
- public InvalidManifestMetadataException(String message){
+ public InvalidManifestMetadataException(String message) {
super(message);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/exceptions/OrchestrationTemplateHandlerException.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/exceptions/OrchestrationTemplateHandlerException.java
index a8a9105254..3f47915fdd 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/exceptions/OrchestrationTemplateHandlerException.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/exceptions/OrchestrationTemplateHandlerException.java
@@ -17,12 +17,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.exceptions;
-public class OrchestrationTemplateHandlerException extends RuntimeException{
+public class OrchestrationTemplateHandlerException extends RuntimeException {
- public OrchestrationTemplateHandlerException(String message, Throwable throwable){
+ public OrchestrationTemplateHandlerException(String message, Throwable throwable) {
super(message, throwable);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java
index 0ac093240d..0b222fd51d 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java
@@ -13,9 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process;
+import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil.ORCHESTRATION_CONFIG_NAMESPACE;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
import org.onap.config.api.Configuration;
import org.onap.config.api.ConfigurationManager;
import org.openecomp.core.utilities.CommonMethods;
@@ -23,49 +27,39 @@ import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
import org.openecomp.sdc.vendorsoftwareproduct.types.ConfigConstants;
-import java.util.Map;
-import java.util.Optional;
-import java.util.concurrent.ConcurrentHashMap;
-
-import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil.ORCHESTRATION_CONFIG_NAMESPACE;
public class OrchestrationProcessFactory {
- private static final Map<String, ImplementationConfiguration> PROCESS_IMPL_MAP;
- private OrchestrationProcessFactory() {
-
- }
-
- static {
- Configuration config = ConfigurationManager.lookup();
- PROCESS_IMPL_MAP = new ConcurrentHashMap<>(config.populateMap(ORCHESTRATION_CONFIG_NAMESPACE,
- ConfigConstants.PROCESS_IMPL_KEY, ImplementationConfiguration.class));
+ private static final Map<String, ImplementationConfiguration> PROCESS_IMPL_MAP;
- }
-
- public static Optional<OrchestrationTemplateProcessHandler> getInstance(String fileSuffix) {
-
- if (fileSuffix == null) {
- return Optional.empty();
+ static {
+ Configuration config = ConfigurationManager.lookup();
+ PROCESS_IMPL_MAP = new ConcurrentHashMap<>(
+ config.populateMap(ORCHESTRATION_CONFIG_NAMESPACE, ConfigConstants.PROCESS_IMPL_KEY, ImplementationConfiguration.class));
}
- String updatedFileSuffix = fileSuffix;
- updatedFileSuffix = updatedFileSuffix.toLowerCase().trim();
- OnboardingTypesEnum onboardingTypesEnum = OnboardingTypesEnum.getOnboardingTypesEnum(updatedFileSuffix);
- if (onboardingTypesEnum == null) {
- return Optional.empty();
+
+ private OrchestrationProcessFactory() {
}
- try {
- return Optional.of(createInstance(PROCESS_IMPL_MAP.get(onboardingTypesEnum.toString())));
- }catch (Exception e){
- return Optional.empty();
+ public static Optional<OrchestrationTemplateProcessHandler> getInstance(String fileSuffix) {
+ if (fileSuffix == null) {
+ return Optional.empty();
+ }
+ String updatedFileSuffix = fileSuffix;
+ updatedFileSuffix = updatedFileSuffix.toLowerCase().trim();
+ OnboardingTypesEnum onboardingTypesEnum = OnboardingTypesEnum.getOnboardingTypesEnum(updatedFileSuffix);
+ if (onboardingTypesEnum == null) {
+ return Optional.empty();
+ }
+ try {
+ return Optional.of(createInstance(PROCESS_IMPL_MAP.get(onboardingTypesEnum.toString())));
+ } catch (Exception e) {
+ return Optional.empty();
+ }
}
- }
- private static OrchestrationTemplateProcessHandler createInstance(ImplementationConfiguration implClass)
- throws Exception {
- OrchestrationTemplateProcessHandler handler;
- handler =
- CommonMethods.newInstance(implClass.getImplementationClass(), OrchestrationTemplateProcessHandler.class);
- return handler;
- }
+ private static OrchestrationTemplateProcessHandler createInstance(ImplementationConfiguration implClass) throws Exception {
+ OrchestrationTemplateProcessHandler handler;
+ handler = CommonMethods.newInstance(implClass.getImplementationClass(), OrchestrationTemplateProcessHandler.class);
+ return handler;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
index 38508c6ec3..8778e0b56b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process;
import java.io.ByteArrayInputStream;
@@ -58,125 +57,107 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTemplateProcessHandler {
- private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationTemplateProcessCsarHandler.class);
- private static final String SDC_ONBOARDED_PACKAGE_DIR = "Deployment/" + ArtifactTypeEnum.ETSI_PACKAGE.getType() + "/";
- private static final String EXT_SEPARATOR = ".";
- private final CandidateService candidateService = CandidateServiceFactory.getInstance().createInterface();
- private final ToscaTreeManager toscaTreeManager = new ToscaTreeManager();
-
- @Override
- public OrchestrationTemplateActionResponse process(VspDetails vspDetails,
- OrchestrationTemplateCandidateData candidateData) {
-
-
- UploadFileResponse uploadFileResponse = new UploadFileResponse();
- Optional<FileContentHandler> fileContent = OrchestrationUtil
- .getFileContentMap(OnboardingTypesEnum.CSAR, uploadFileResponse,
- candidateData.getContentData().array());
-
- OrchestrationTemplateActionResponse response = new OrchestrationTemplateActionResponse();
- if (fileContent.isPresent()) {
- try {
- FileContentHandler fileContentHandler = fileContent.get();
- processCsar(vspDetails, fileContentHandler, candidateData, response);
- } catch (CoreException e) {
- LOGGER.error(e.getMessage(), e);
- response.addErrorMessageToMap(e.code().id(), e.code().message(),ErrorLevel.ERROR);
- }catch (IOException e){
- LOGGER.error(e.getMessage(), e);
- response.addErrorMessageToMap(SdcCommon.PROCESS_FILE, e.getMessage(), ErrorLevel.ERROR);
- }
- } else {
- if (!uploadFileResponse.getErrors().isEmpty()) {
- response.addStructureErrors(uploadFileResponse.getErrors());
- }
+ private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationTemplateProcessCsarHandler.class);
+ private static final String SDC_ONBOARDED_PACKAGE_DIR = "Deployment/" + ArtifactTypeEnum.ETSI_PACKAGE.getType() + "/";
+ private static final String EXT_SEPARATOR = ".";
+ private final CandidateService candidateService = CandidateServiceFactory.getInstance().createInterface();
+ private final ToscaTreeManager toscaTreeManager = new ToscaTreeManager();
+
+ @Override
+ public OrchestrationTemplateActionResponse process(VspDetails vspDetails, OrchestrationTemplateCandidateData candidateData) {
+ UploadFileResponse uploadFileResponse = new UploadFileResponse();
+ Optional<FileContentHandler> fileContent = OrchestrationUtil
+ .getFileContentMap(OnboardingTypesEnum.CSAR, uploadFileResponse, candidateData.getContentData().array());
+ OrchestrationTemplateActionResponse response = new OrchestrationTemplateActionResponse();
+ if (fileContent.isPresent()) {
+ try {
+ FileContentHandler fileContentHandler = fileContent.get();
+ processCsar(vspDetails, fileContentHandler, candidateData, response);
+ } catch (CoreException e) {
+ LOGGER.error(e.getMessage(), e);
+ response.addErrorMessageToMap(e.code().id(), e.code().message(), ErrorLevel.ERROR);
+ } catch (IOException e) {
+ LOGGER.error(e.getMessage(), e);
+ response.addErrorMessageToMap(SdcCommon.PROCESS_FILE, e.getMessage(), ErrorLevel.ERROR);
+ }
+ } else {
+ if (!uploadFileResponse.getErrors().isEmpty()) {
+ response.addStructureErrors(uploadFileResponse.getErrors());
+ }
+ }
+ return response;
}
- return response;
- }
-
- private void processCsar(VspDetails vspDetails,
- FileContentHandler fileContentHandler,
- OrchestrationTemplateCandidateData candidateData,
- OrchestrationTemplateActionResponse response) throws IOException{
- response.setFileNames(new ArrayList<>(fileContentHandler.getFileList()));
- Map<String, List<ErrorMessage>> errors = validateCsar(fileContentHandler);
- toscaTreeManager.createTree();
- if (!isValid(errors)) {
- response.addStructureErrors(errors);
- toscaTreeManager.addErrors(errors);
- candidateService.updateValidationData(vspDetails.getId(), vspDetails.getVersion(),
- new ValidationStructureList(toscaTreeManager.getTree()));
- return;
+ private void processCsar(VspDetails vspDetails, FileContentHandler fileContentHandler, OrchestrationTemplateCandidateData candidateData,
+ OrchestrationTemplateActionResponse response) throws IOException {
+ response.setFileNames(new ArrayList<>(fileContentHandler.getFileList()));
+ Map<String, List<ErrorMessage>> errors = validateCsar(fileContentHandler);
+ toscaTreeManager.createTree();
+ if (!isValid(errors)) {
+ response.addStructureErrors(errors);
+ toscaTreeManager.addErrors(errors);
+ candidateService
+ .updateValidationData(vspDetails.getId(), vspDetails.getVersion(), new ValidationStructureList(toscaTreeManager.getTree()));
+ return;
+ }
+ HeatStructureTree tree = toscaTreeManager.getTree();
+ Map<String, String> componentsQuestionnaire = new HashMap<>();
+ Map<String, Map<String, String>> componentNicsQuestionnaire = new HashMap<>();
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList = new HashMap<>();
+ Map<String, Collection<ProcessEntity>> processes = new HashMap<>();
+ Map<String, ProcessEntity> processArtifact = new HashMap<>();
+ OrchestrationUtil orchestrationUtil = new OrchestrationUtil();
+ orchestrationUtil.backupComponentsQuestionnaireBeforeDelete(vspDetails.getId(), vspDetails.getVersion(), componentsQuestionnaire,
+ componentNicsQuestionnaire, componentMibList, processes, processArtifact);
+ Optional<ByteArrayInputStream> zipByteArrayInputStream = candidateService
+ .fetchZipFileByteArrayInputStream(vspDetails.getId(), candidateData, null, OnboardingTypesEnum.CSAR, errors);
+ orchestrationUtil.deleteUploadDataAndContent(vspDetails.getId(), vspDetails.getVersion());
+ zipByteArrayInputStream.ifPresent(
+ byteArrayInputStream -> orchestrationUtil.saveUploadData(vspDetails, candidateData, byteArrayInputStream, fileContentHandler, tree));
+ ETSIService etsiService = new ETSIServiceImpl();
+ ToscaServiceModel toscaServiceModel;
+ if (etsiService.isSol004WithToscaMetaDirectory(fileContentHandler)) {
+ if (OnboardingTypesEnum.CSAR.toString().equalsIgnoreCase(candidateData.getFileSuffix())) {
+ fileContentHandler
+ .addFile(SDC_ONBOARDED_PACKAGE_DIR + candidateData.getOriginalFileName() + EXT_SEPARATOR + candidateData.getOriginalFileSuffix(),
+ candidateData.getOriginalFileContentData().array());
+ } else {
+ fileContentHandler.addFile(SDC_ONBOARDED_PACKAGE_DIR + candidateData.getFileName() + EXT_SEPARATOR + candidateData.getFileSuffix(),
+ candidateData.getContentData().array());
+ }
+ final ResourceTypeEnum resourceType = etsiService.getResourceType(fileContentHandler);
+ toscaServiceModel = instantiateToscaConverterFor(resourceType).convert(fileContentHandler);
+ } else {
+ toscaServiceModel = new ToscaConverterImpl().convert(fileContentHandler);
+ }
+ orchestrationUtil.saveServiceModel(vspDetails.getId(), vspDetails.getVersion(), toscaServiceModel, toscaServiceModel);
+ candidateService.deleteOrchestrationTemplateCandidate(vspDetails.getId(), vspDetails.getVersion());
}
- HeatStructureTree tree = toscaTreeManager.getTree();
-
- Map<String, String> componentsQuestionnaire = new HashMap<>();
- Map<String, Map<String, String>> componentNicsQuestionnaire = new HashMap<>();
- Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList = new HashMap<>();
- Map<String, Collection<ProcessEntity>> processes = new HashMap<>();
- Map<String, ProcessEntity> processArtifact = new HashMap<>();
- OrchestrationUtil orchestrationUtil = new OrchestrationUtil();
- orchestrationUtil.backupComponentsQuestionnaireBeforeDelete(vspDetails.getId(),
- vspDetails.getVersion(), componentsQuestionnaire,
- componentNicsQuestionnaire, componentMibList, processes, processArtifact);
-
- Optional<ByteArrayInputStream> zipByteArrayInputStream = candidateService
- .fetchZipFileByteArrayInputStream(vspDetails.getId(), candidateData, null,
- OnboardingTypesEnum.CSAR, errors);
-
- orchestrationUtil.deleteUploadDataAndContent(vspDetails.getId(), vspDetails.getVersion());
- zipByteArrayInputStream.ifPresent(byteArrayInputStream -> orchestrationUtil
- .saveUploadData(vspDetails, candidateData, byteArrayInputStream,
- fileContentHandler, tree));
-
- ETSIService etsiService = new ETSIServiceImpl();
- ToscaServiceModel toscaServiceModel;
- if (etsiService.isSol004WithToscaMetaDirectory(fileContentHandler)) {
- if (OnboardingTypesEnum.CSAR.toString().equalsIgnoreCase(candidateData.getFileSuffix())) {
- fileContentHandler.addFile(SDC_ONBOARDED_PACKAGE_DIR + candidateData.getOriginalFileName() +
- EXT_SEPARATOR + candidateData.getOriginalFileSuffix(), candidateData.getOriginalFileContentData().array());
- } else {
- fileContentHandler.addFile(SDC_ONBOARDED_PACKAGE_DIR + candidateData.getFileName() +
- EXT_SEPARATOR + candidateData.getFileSuffix(), candidateData.getContentData().array());
- }
- final ResourceTypeEnum resourceType = etsiService.getResourceType(fileContentHandler);
- toscaServiceModel = instantiateToscaConverterFor(resourceType).convert(fileContentHandler);
- } else {
- toscaServiceModel = new ToscaConverterImpl().convert(fileContentHandler);
+ private AbstractToscaSolConverter instantiateToscaConverterFor(ResourceTypeEnum resourceType) {
+ if (resourceType == ResourceTypeEnum.PNF) {
+ return new ToscaSolModelDrivenConverterPnf();
+ }
+ // default is VF
+ return new ToscaSolConverterVnf();
}
- orchestrationUtil.saveServiceModel(vspDetails.getId(),
- vspDetails.getVersion(), toscaServiceModel,
- toscaServiceModel);
- candidateService
- .deleteOrchestrationTemplateCandidate(vspDetails.getId(), vspDetails.getVersion());
- }
- private AbstractToscaSolConverter instantiateToscaConverterFor(ResourceTypeEnum resourceType) {
- if (resourceType == ResourceTypeEnum.PNF) {
- return new ToscaSolModelDrivenConverterPnf();
+ private void addFiles(FileContentHandler fileContentHandler) {
+ for (Map.Entry<String, byte[]> fileEntry : fileContentHandler.getFiles().entrySet()) {
+ toscaTreeManager.addFile(fileEntry.getKey(), fileEntry.getValue());
+ }
}
- // default is VF
- return new ToscaSolConverterVnf();
- }
- private void addFiles(FileContentHandler fileContentHandler) {
- for (Map.Entry<String, byte[]> fileEntry : fileContentHandler.getFiles().entrySet()) {
- toscaTreeManager.addFile(fileEntry.getKey(), fileEntry.getValue());
+ private Map<String, List<ErrorMessage>> validateCsar(FileContentHandler fileContentHandler) {
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ addFiles(fileContentHandler);
+ toscaTreeManager.createTree();
+ toscaTreeManager.addErrors(errors);
+ //todo - add tosca validation here to the existing validation framework
+ return errors;
}
- }
-
- private Map<String, List<ErrorMessage>> validateCsar(FileContentHandler fileContentHandler) {
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- addFiles(fileContentHandler);
- toscaTreeManager.createTree();
- toscaTreeManager.addErrors(errors);
- //todo - add tosca validation here to the existing validation framework
- return errors;
- }
- private boolean isValid(Map<String, List<ErrorMessage>> errors) {
- return MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, errors));
- }
+ private boolean isValid(Map<String, List<ErrorMessage>> errors) {
+ return MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, errors));
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessHandler.java
index c775ac2c84..ae555b78a0 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessHandler.java
@@ -13,10 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process;
-
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
@@ -24,6 +22,5 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateAction
@FunctionalInterface
public interface OrchestrationTemplateProcessHandler {
- OrchestrationTemplateActionResponse process(VspDetails vspDetails,
- OrchestrationTemplateCandidateData candidateData);
+ OrchestrationTemplateActionResponse process(VspDetails vspDetails, OrchestrationTemplateCandidateData candidateData);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java
index 2d18a62122..5f18cb2faa 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java
@@ -14,9 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.translator.datatypes.TranslatorOutput;
@@ -37,7 +46,11 @@ import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil;
import org.openecomp.sdc.validation.util.ValidationManagerUtil;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.*;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil;
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
@@ -47,157 +60,119 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStru
import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.*;
-
public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemplateProcessHandler {
- private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationTemplateProcessZipHandler.class);
- private final CandidateService candidateService =
- CandidateServiceFactory.getInstance().createInterface();
-
- @Override
- public OrchestrationTemplateActionResponse process(VspDetails vspDetails,
- OrchestrationTemplateCandidateData candidateData) {
- String vspId = vspDetails.getId();
- Version version = vspDetails.getVersion();
- OrchestrationTemplateActionResponse response = new OrchestrationTemplateActionResponse();
- UploadFileResponse uploadFileResponse = new UploadFileResponse();
- Optional<FileContentHandler> fileContent = OrchestrationUtil
- .getFileContentMap(OnboardingTypesEnum.ZIP, uploadFileResponse,
- candidateData.getContentData().array());
- if (!fileContent.isPresent()) {
- response.addStructureErrors(uploadFileResponse.getErrors());
- return response;
- }
-
- Map<String, List<ErrorMessage>> uploadErrors = uploadFileResponse.getErrors();
- FileContentHandler fileContentMap = fileContent.get();
- try (InputStream zipFileManifest = fileContentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) {
- addDummyHeatBase(zipFileManifest ,fileContentMap);
- } catch (Exception e) {
- LOGGER.error("Invalid package content", e);
- }
- FilesDataStructure structure =
- JsonUtil.json2Object(candidateData.getFilesDataStructure(), FilesDataStructure.class);
-
- if (CollectionUtils.isNotEmpty(structure.getUnassigned())) {
- response.addErrorMessageToMap(SdcCommon.UPLOAD_FILE,
- Messages.FOUND_UNASSIGNED_FILES.getErrorMessage(), ErrorLevel.ERROR);
- return response;
- }
-
-
- ManifestContent zipManifestFile = readManifestFromZip(fileContentMap);
- String manifest = null;
- if (zipManifestFile == null) {
- manifest = candidateService.createManifest(vspDetails, structure);
- } else {
- manifest = candidateService.createManifestFromExisting(vspDetails, structure, zipManifestFile);
+ private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationTemplateProcessZipHandler.class);
+ private final CandidateService candidateService = CandidateServiceFactory.getInstance().createInterface();
+
+ @Override
+ public OrchestrationTemplateActionResponse process(VspDetails vspDetails, OrchestrationTemplateCandidateData candidateData) {
+ String vspId = vspDetails.getId();
+ Version version = vspDetails.getVersion();
+ OrchestrationTemplateActionResponse response = new OrchestrationTemplateActionResponse();
+ UploadFileResponse uploadFileResponse = new UploadFileResponse();
+ Optional<FileContentHandler> fileContent = OrchestrationUtil
+ .getFileContentMap(OnboardingTypesEnum.ZIP, uploadFileResponse, candidateData.getContentData().array());
+ if (!fileContent.isPresent()) {
+ response.addStructureErrors(uploadFileResponse.getErrors());
+ return response;
+ }
+ Map<String, List<ErrorMessage>> uploadErrors = uploadFileResponse.getErrors();
+ FileContentHandler fileContentMap = fileContent.get();
+ try (InputStream zipFileManifest = fileContentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) {
+ addDummyHeatBase(zipFileManifest, fileContentMap);
+ } catch (Exception e) {
+ LOGGER.error("Invalid package content", e);
+ }
+ FilesDataStructure structure = JsonUtil.json2Object(candidateData.getFilesDataStructure(), FilesDataStructure.class);
+ if (CollectionUtils.isNotEmpty(structure.getUnassigned())) {
+ response.addErrorMessageToMap(SdcCommon.UPLOAD_FILE, Messages.FOUND_UNASSIGNED_FILES.getErrorMessage(), ErrorLevel.ERROR);
+ return response;
+ }
+ ManifestContent zipManifestFile = readManifestFromZip(fileContentMap);
+ String manifest = null;
+ if (zipManifestFile == null) {
+ manifest = candidateService.createManifest(vspDetails, structure);
+ } else {
+ manifest = candidateService.createManifestFromExisting(vspDetails, structure, zipManifestFile);
+ }
+ fileContentMap.addFile(SdcCommon.MANIFEST_NAME, manifest.getBytes());
+ Optional<ByteArrayInputStream> zipByteArrayInputStream = candidateService
+ .fetchZipFileByteArrayInputStream(vspId, candidateData, manifest, OnboardingTypesEnum.ZIP, uploadErrors);
+ if (!zipByteArrayInputStream.isPresent()) {
+ return response;
+ }
+ HeatStructureTree tree = createAndValidateHeatTree(response, fileContentMap);
+ Map<String, List<ErrorMessage>> errors = getErrors(response);
+ if (MapUtils.isNotEmpty(errors)) {
+ response.addStructureErrors(errors);
+ candidateService.updateValidationData(vspId, version, new ValidationStructureList(tree));
+ return response;
+ }
+ Map<String, String> componentsQuestionnaire = new HashMap<>();
+ Map<String, Map<String, String>> componentNicsQuestionnaire = new HashMap<>();
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList = new HashMap<>();
+ Map<String, Collection<ProcessEntity>> processes = new HashMap<>();
+ Map<String, ProcessEntity> processArtifact = new HashMap<>();
+ OrchestrationUtil orchestrationUtil = new OrchestrationUtil();
+ Map<String, String> vspComponentIdNameInfoBeforeProcess = orchestrationUtil.getVspComponentIdNameInfo(vspId, version);
+ Collection<ComponentDependencyModelEntity> componentDependenciesBeforeDelete = orchestrationUtil
+ .getComponentDependenciesBeforeDelete(vspId, version);
+ orchestrationUtil
+ .backupComponentsQuestionnaireBeforeDelete(vspId, version, componentsQuestionnaire, componentNicsQuestionnaire, componentMibList,
+ processes, processArtifact);
+ orchestrationUtil.deleteUploadDataAndContent(vspId, version);
+ orchestrationUtil.saveUploadData(vspDetails, candidateData, zipByteArrayInputStream.get(), fileContentMap, tree);
+ TranslatorOutput translatorOutput = HeatToToscaUtil.loadAndTranslateTemplateData(fileContentMap);
+ ToscaServiceModel toscaServiceModel = translatorOutput.getToscaServiceModel();
+ orchestrationUtil.saveServiceModel(vspId, version, translatorOutput.getNonUnifiedToscaServiceModel(), toscaServiceModel);
+ orchestrationUtil
+ .retainComponentQuestionnaireData(vspId, version, componentsQuestionnaire, componentNicsQuestionnaire, componentMibList, processes,
+ processArtifact);
+ orchestrationUtil.updateVspComponentDependencies(vspId, version, vspComponentIdNameInfoBeforeProcess, componentDependenciesBeforeDelete);
+ uploadFileResponse.addStructureErrors(uploadErrors);
+ candidateService.deleteOrchestrationTemplateCandidate(vspId, version);
+ return response;
}
- fileContentMap.addFile(SdcCommon.MANIFEST_NAME, manifest.getBytes());
- Optional<ByteArrayInputStream> zipByteArrayInputStream = candidateService
- .fetchZipFileByteArrayInputStream(
- vspId, candidateData, manifest, OnboardingTypesEnum.ZIP, uploadErrors);
- if (!zipByteArrayInputStream.isPresent()) {
- return response;
+ private ManifestContent readManifestFromZip(FileContentHandler fileContentMap) {
+ ManifestContent zipManifestFile = null;
+ try (InputStream zipFileManifest = fileContentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) {
+ zipManifestFile = JsonUtil.json2Object(zipFileManifest, ManifestContent.class);
+ } catch (Exception e) {
+ LOGGER.error("Invalid package content", e);
+ }
+ return zipManifestFile;
}
- HeatStructureTree tree = createAndValidateHeatTree(response, fileContentMap);
- Map<String, List<ErrorMessage>> errors = getErrors(response);
- if (MapUtils.isNotEmpty(errors)) {
- response.addStructureErrors(errors);
- candidateService.updateValidationData(vspId, version, new ValidationStructureList(tree));
- return response;
+ private FileContentHandler addDummyHeatBase(InputStream zipFileManifest, FileContentHandler fileContentMap) {
+ ManifestContent manifestContent = JsonUtil.json2Object(zipFileManifest, ManifestContent.class);
+ for (FileData fileData : manifestContent.getData()) {
+ if (Objects.nonNull(fileData.getType()) && fileData.getType().equals(FileData.Type.HELM) && fileData.getBase()) {
+ String filePath = new File("").getAbsolutePath() + "/resources";
+ File envFilePath = new File(filePath + "/base_template.env");
+ File baseFilePath = new File(filePath + "/base_template.yaml");
+ try (InputStream envStream = new FileInputStream(envFilePath); InputStream baseStream = new FileInputStream(baseFilePath);) {
+ fileContentMap.addFile("base_template_dummy_ignore.env", envStream);
+ fileContentMap.addFile("base_template_dummy_ignore.yaml", baseStream);
+ } catch (Exception e) {
+ LOGGER.error("File not found error {}", e);
+ }
+ }
+ }
+ return fileContentMap;
}
- Map<String, String> componentsQuestionnaire = new HashMap<>();
- Map<String, Map<String, String>> componentNicsQuestionnaire = new HashMap<>();
- Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList = new HashMap<>();
- Map<String, Collection<ProcessEntity>> processes = new HashMap<>();
- Map<String, ProcessEntity> processArtifact = new HashMap<>();
-
- OrchestrationUtil orchestrationUtil = new OrchestrationUtil();
- Map<String, String> vspComponentIdNameInfoBeforeProcess =
- orchestrationUtil.getVspComponentIdNameInfo(vspId, version);
- Collection<ComponentDependencyModelEntity> componentDependenciesBeforeDelete =
- orchestrationUtil.getComponentDependenciesBeforeDelete(vspId, version);
- orchestrationUtil
- .backupComponentsQuestionnaireBeforeDelete(vspId, version, componentsQuestionnaire,
- componentNicsQuestionnaire, componentMibList, processes, processArtifact);
- orchestrationUtil.deleteUploadDataAndContent(vspId, version);
- orchestrationUtil
- .saveUploadData(vspDetails, candidateData, zipByteArrayInputStream.get(), fileContentMap,
- tree);
-
- TranslatorOutput translatorOutput =
- HeatToToscaUtil.loadAndTranslateTemplateData(fileContentMap);
-
- ToscaServiceModel toscaServiceModel = translatorOutput.getToscaServiceModel();
- orchestrationUtil
- .saveServiceModel(vspId, version, translatorOutput.getNonUnifiedToscaServiceModel(),
- toscaServiceModel);
- orchestrationUtil.retainComponentQuestionnaireData(vspId, version, componentsQuestionnaire,
- componentNicsQuestionnaire, componentMibList, processes, processArtifact);
- orchestrationUtil.updateVspComponentDependencies(vspId, version,
- vspComponentIdNameInfoBeforeProcess, componentDependenciesBeforeDelete);
-
- uploadFileResponse.addStructureErrors(uploadErrors);
- candidateService.deleteOrchestrationTemplateCandidate(vspId, version);
- return response;
- }
-
- private ManifestContent readManifestFromZip(FileContentHandler fileContentMap) {
- ManifestContent zipManifestFile = null;
- try (InputStream zipFileManifest = fileContentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) {
- zipManifestFile = JsonUtil.json2Object(zipFileManifest, ManifestContent.class);
- } catch (Exception e) {
- LOGGER.error("Invalid package content", e);
+ private Map<String, List<ErrorMessage>> getErrors(OrchestrationTemplateActionResponse orchestrationTemplateActionResponse) {
+ Map<String, List<ErrorMessage>> errors = MessageContainerUtil
+ .getMessageByLevel(ErrorLevel.ERROR, orchestrationTemplateActionResponse.getErrors());
+ return MapUtils.isEmpty(errors) ? null : orchestrationTemplateActionResponse.getErrors();
}
- return zipManifestFile;
- }
- private FileContentHandler addDummyHeatBase(InputStream zipFileManifest, FileContentHandler fileContentMap) {
- ManifestContent manifestContent =
- JsonUtil.json2Object(zipFileManifest, ManifestContent.class);
- for (FileData fileData : manifestContent.getData()) {
- if (Objects.nonNull(fileData.getType()) &&
- fileData.getType().equals(FileData.Type.HELM) && fileData.getBase()) {
- String filePath = new File("").getAbsolutePath() + "/resources";
- File envFilePath = new File(filePath + "/base_template.env");
- File baseFilePath = new File(filePath + "/base_template.yaml");
- try (
- InputStream envStream = new FileInputStream(envFilePath);
- InputStream baseStream = new FileInputStream(baseFilePath);) {
- fileContentMap.addFile("base_template_dummy_ignore.env", envStream);
- fileContentMap.addFile("base_template_dummy_ignore.yaml", baseStream);
- } catch (Exception e) {
- LOGGER.error("File not found error {}", e);
- }
- }
+ private HeatStructureTree createAndValidateHeatTree(OrchestrationTemplateActionResponse response, FileContentHandler fileContentMap) {
+ VendorSoftwareProductUtils.addFileNamesToUploadFileResponse(fileContentMap, response);
+ Map<String, List<ErrorMessage>> validationErrors = ValidationManagerUtil.initValidationManager(fileContentMap).validate();
+ response.getErrors().putAll(validationErrors);
+ return OrchestrationUtil.createHeatTree(fileContentMap, validationErrors);
}
- return fileContentMap;
- }
-
- private Map<String, List<ErrorMessage>> getErrors(OrchestrationTemplateActionResponse
- orchestrationTemplateActionResponse) {
- Map<String, List<ErrorMessage>> errors =
- MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR,
- orchestrationTemplateActionResponse.getErrors());
- return MapUtils.isEmpty(errors) ? null : orchestrationTemplateActionResponse.getErrors();
- }
-
- private HeatStructureTree createAndValidateHeatTree(OrchestrationTemplateActionResponse response,
- FileContentHandler fileContentMap) {
- VendorSoftwareProductUtils.addFileNamesToUploadFileResponse(fileContentMap, response);
- Map<String, List<ErrorMessage>> validationErrors =
- ValidationManagerUtil.initValidationManager(fileContentMap).validate();
- response.getErrors().putAll(validationErrors);
-
- return OrchestrationUtil.createHeatTree(fileContentMap, validationErrors);
- }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/security/SecurityManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/security/SecurityManager.java
index 006af058bb..d60b54b5e1 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/security/SecurityManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/security/SecurityManager.java
@@ -20,8 +20,13 @@
package org.openecomp.sdc.vendorsoftwareproduct.security;
import com.google.common.collect.ImmutableSet;
-
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.security.GeneralSecurityException;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
@@ -41,12 +46,11 @@ import java.security.cert.X509CertSelector;
import java.security.cert.X509Certificate;
import java.util.Collection;
import java.util.HashSet;
-import java.util.function.Predicate;
import java.util.Optional;
+import java.util.Set;
+import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import java.util.Set;
-
import org.bouncycastle.asn1.cms.ContentInfo;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.cms.CMSException;
@@ -62,16 +66,14 @@ import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
/**
- * This is temporary solution. When AAF provides functionality for verifying trustedCertificates, this class should be
- * reviewed Class is responsible for providing root trustedCertificates from configured location in onboarding
- * container.
+ * This is temporary solution. When AAF provides functionality for verifying trustedCertificates, this class should be reviewed Class is responsible
+ * for providing root trustedCertificates from configured location in onboarding container.
*/
public class SecurityManager {
private static final String CERTIFICATE_DEFAULT_LOCATION = "cert";
public static final Set<String> ALLOWED_SIGNATURE_EXTENSIONS = ImmutableSet.of("cms");
public static final Set<String> ALLOWED_CERTIFICATE_EXTENSIONS = ImmutableSet.of("cert", "crt");
-
private Logger logger = LoggerFactory.getLogger(SecurityManager.class);
private Set<X509Certificate> trustedCertificates = new HashSet<>();
private Set<X509Certificate> trustedCertificatesFromPackage = new HashSet<>();
@@ -87,7 +89,6 @@ public class SecurityManager {
certificateDirectory = this.getcertDirectory(System.getenv("SDC_CERT_DIR"));
}
-
// Package level constructor use in tests to avoid power mock
SecurityManager(String sdcCertDir) {
certificateDirectory = this.getcertDirectory(sdcCertDir);
@@ -123,8 +124,7 @@ public class SecurityManager {
processCertificateDir();
}
if (!trustedCertificatesFromPackage.isEmpty()) {
- return Stream.concat(trustedCertificatesFromPackage.stream(), trustedCertificates.stream())
- .collect(Collectors.toUnmodifiableSet());
+ return Stream.concat(trustedCertificatesFromPackage.stream(), trustedCertificates.stream()).collect(Collectors.toUnmodifiableSet());
}
return ImmutableSet.copyOf(trustedCertificates);
}
@@ -145,10 +145,10 @@ public class SecurityManager {
* @return true if signature verified
* @throws SecurityManagerException
*/
- public boolean verifySignedData(final byte[] messageSyntaxSignature, final byte[] packageCert,
- final byte[] innerPackageFile) throws SecurityManagerException {
- try (ByteArrayInputStream signatureStream = new ByteArrayInputStream(messageSyntaxSignature);
- final PEMParser pemParser = new PEMParser(new InputStreamReader(signatureStream))) {
+ public boolean verifySignedData(final byte[] messageSyntaxSignature, final byte[] packageCert, final byte[] innerPackageFile)
+ throws SecurityManagerException {
+ try (ByteArrayInputStream signatureStream = new ByteArrayInputStream(messageSyntaxSignature); final PEMParser pemParser = new PEMParser(
+ new InputStreamReader(signatureStream))) {
final Object parsedObject = pemParser.readObject();
if (!(parsedObject instanceof ContentInfo)) {
throw new SecurityManagerException("Signature is not recognized");
@@ -156,26 +156,23 @@ public class SecurityManager {
final ContentInfo signature = ContentInfo.getInstance(parsedObject);
final CMSTypedData signedContent = new CMSProcessableByteArray(innerPackageFile);
final CMSSignedData signedData = new CMSSignedData(signedContent, signature);
-
final Collection<SignerInformation> signers = signedData.getSignerInfos().getSigners();
final SignerInformation firstSigner = signers.iterator().next();
final X509Certificate cert;
Collection<X509CertificateHolder> certs;
if (packageCert == null) {
certs = signedData.getCertificates().getMatches(null);
- cert = readSignCert(certs, firstSigner).orElseThrow(() -> new SecurityManagerException(
- "No certificate found in cms signature that should contain one!"));
+ cert = readSignCert(certs, firstSigner)
+ .orElseThrow(() -> new SecurityManagerException("No certificate found in cms signature that should contain one!"));
} else {
certs = parseCertsFromPem(packageCert);
- cert = readSignCert(certs, firstSigner).orElseThrow(() -> new SecurityManagerException(
- "No matching certificate found in certificate file that should contain one!"));
+ cert = readSignCert(certs, firstSigner)
+ .orElseThrow(() -> new SecurityManagerException("No matching certificate found in certificate file that should contain one!"));
}
trustedCertificatesFromPackage = readTrustedCerts(certs, firstSigner);
-
if (verifyCertificate(cert, getTrustedCertificates()) == null) {
return false;
}
-
return firstSigner.verify(new JcaSimpleSignerInfoVerifierBuilder().build(cert));
} catch (OperatorCreationException | IOException | CMSException e) {
logger.error(e.getMessage(), e);
@@ -186,18 +183,12 @@ public class SecurityManager {
}
private Optional<X509Certificate> readSignCert(final Collection<X509CertificateHolder> certs, final SignerInformation firstSigner) {
- return certs.stream()
- .filter(crt -> firstSigner.getSID().match(crt))
- .findAny()
- .map(this::loadCertificate);
+ return certs.stream().filter(crt -> firstSigner.getSID().match(crt)).findAny().map(this::loadCertificate);
}
private Set<X509Certificate> readTrustedCerts(final Collection<X509CertificateHolder> certs, final SignerInformation firstSigner) {
- return certs.stream()
- .filter(crt -> !firstSigner.getSID().match(crt))
- .map(this::loadCertificate)
- .filter(Predicate.not(this::isSelfSigned))
- .collect(Collectors.toSet());
+ return certs.stream().filter(crt -> !firstSigner.getSID().match(crt)).map(this::loadCertificate).filter(Predicate.not(this::isSelfSigned))
+ .collect(Collectors.toSet());
}
private Set<X509CertificateHolder> parseCertsFromPem(final byte[] packageCert) throws IOException {
@@ -219,7 +210,6 @@ public class SecurityManager {
logger.error("Issue with certificate directory, check if exists!");
return;
}
-
File[] files = certificateDirectory.listFiles();
if (files == null) {
logger.error("Certificate directory is empty!");
@@ -238,10 +228,10 @@ public class SecurityManager {
return new File(certDirLocation);
}
- private X509Certificate loadCertificate(File certFile) throws SecurityManagerException {
+ private X509Certificate loadCertificate(File certFile) throws SecurityManagerException {
try (FileInputStream fi = new FileInputStream(certFile)) {
return loadCertificateFactory(fi);
- } catch(IOException e) {
+ } catch (IOException e) {
throw new SecurityManagerException("Error during loading Certificate from file!", e);
}
}
@@ -263,21 +253,17 @@ public class SecurityManager {
}
}
- private PKIXCertPathBuilderResult verifyCertificate(X509Certificate cert,
- Set<X509Certificate> additionalCerts)
- throws GeneralSecurityException, SecurityManagerException {
+ private PKIXCertPathBuilderResult verifyCertificate(X509Certificate cert, Set<X509Certificate> additionalCerts)
+ throws GeneralSecurityException, SecurityManagerException {
if (null == cert) {
throw new SecurityManagerException("The certificate is empty!");
}
-
if (isExpired(cert)) {
throw new SecurityManagerException("The certificate expired on: " + cert.getNotAfter());
}
-
if (isSelfSigned(cert)) {
throw new SecurityManagerException("The certificate is self-signed.");
}
-
Set<X509Certificate> trustedRootCerts = new HashSet<>();
Set<X509Certificate> intermediateCerts = new HashSet<>();
for (X509Certificate additionalCert : additionalCerts) {
@@ -287,25 +273,19 @@ public class SecurityManager {
intermediateCerts.add(additionalCert);
}
}
-
return verifyCertificate(cert, trustedRootCerts, intermediateCerts);
}
- private PKIXCertPathBuilderResult verifyCertificate(X509Certificate cert,
- Set<X509Certificate> allTrustedRootCerts,
- Set<X509Certificate> allIntermediateCerts)
- throws GeneralSecurityException {
-
+ private PKIXCertPathBuilderResult verifyCertificate(X509Certificate cert, Set<X509Certificate> allTrustedRootCerts,
+ Set<X509Certificate> allIntermediateCerts) throws GeneralSecurityException {
// Create the selector that specifies the starting certificate
X509CertSelector selector = new X509CertSelector();
selector.setCertificate(cert);
-
// Create the trust anchors (set of root CA certificates)
Set<TrustAnchor> trustAnchors = new HashSet<>();
for (X509Certificate trustedRootCert : allTrustedRootCerts) {
trustAnchors.add(new TrustAnchor(trustedRootCert, null));
}
-
// Configure the PKIX certificate builder algorithm parameters
PKIXBuilderParameters pkixParams;
try {
@@ -313,25 +293,20 @@ public class SecurityManager {
} catch (InvalidAlgorithmParameterException ex) {
throw new InvalidAlgorithmParameterException("No root CA has been found for this certificate", ex);
}
-
// Not supporting CRL checks for now
pkixParams.setRevocationEnabled(false);
-
Set<X509Certificate> certSet = new HashSet<>();
certSet.add(cert);
pkixParams.addCertStore(createCertStore(certSet));
pkixParams.addCertStore(createCertStore(allIntermediateCerts));
pkixParams.addCertStore(createCertStore(allTrustedRootCerts));
-
- CertPathBuilder builder = CertPathBuilder
- .getInstance(CertPathBuilder.getDefaultType(), BouncyCastleProvider.PROVIDER_NAME);
+ CertPathBuilder builder = CertPathBuilder.getInstance(CertPathBuilder.getDefaultType(), BouncyCastleProvider.PROVIDER_NAME);
return (PKIXCertPathBuilderResult) builder.build(pkixParams);
}
- private CertStore createCertStore(Set<X509Certificate> certificateSet) throws InvalidAlgorithmParameterException,
- NoSuchAlgorithmException, NoSuchProviderException {
- return CertStore.getInstance("Collection", new CollectionCertStoreParameters(certificateSet),
- BouncyCastleProvider.PROVIDER_NAME);
+ private CertStore createCertStore(Set<X509Certificate> certificateSet)
+ throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException {
+ return CertStore.getInstance("Collection", new CollectionCertStoreParameters(certificateSet), BouncyCastleProvider.PROVIDER_NAME);
}
private boolean isExpired(X509Certificate cert) {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResult.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResult.java
index a8d528c503..ed38b61e81 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResult.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResult.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,28 +17,26 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types;
-
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
-
import java.util.Set;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
public class ComponentValidationResult {
- private boolean valid;
- private Set<CompositionEntityValidationData> validationData;
- public ComponentValidationResult(Set<CompositionEntityValidationData> validationData) {
- this.validationData = validationData;
- valid = validationData == null;
- }
+ private boolean valid;
+ private Set<CompositionEntityValidationData> validationData;
+
+ public ComponentValidationResult(Set<CompositionEntityValidationData> validationData) {
+ this.validationData = validationData;
+ valid = validationData == null;
+ }
- public boolean isValid() {
- return valid;
- }
+ public boolean isValid() {
+ return valid;
+ }
- public Set<CompositionEntityValidationData> getValidationData() {
- return validationData;
- }
+ public Set<CompositionEntityValidationData> getValidationData() {
+ return validationData;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CompositionEntityResponse.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CompositionEntityResponse.java
index 24d28b198a..90518b93d0 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CompositionEntityResponse.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CompositionEntityResponse.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,38 +17,37 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionDataEntity;
public class CompositionEntityResponse<T extends CompositionDataEntity> {
- private String id;
- private String schema;
- private T data;
+ private String id;
+ private String schema;
+ private T data;
- public String getId() {
- return id;
- }
+ public String getId() {
+ return id;
+ }
- public void setId(String id) {
- this.id = id;
- }
+ public void setId(String id) {
+ this.id = id;
+ }
- public String getSchema() {
- return schema;
- }
+ public String getSchema() {
+ return schema;
+ }
- public void setSchema(String schema) {
- this.schema = schema;
- }
+ public void setSchema(String schema) {
+ this.schema = schema;
+ }
- public T getData() {
- return data;
- }
+ public T getData() {
+ return data;
+ }
- public void setData(T data) {
- this.data = data;
- }
+ public void setData(T data) {
+ this.data = data;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ConfigConstants.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ConfigConstants.java
index 640d0c9bbc..35b6851a9b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ConfigConstants.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ConfigConstants.java
@@ -13,14 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types;
public class ConfigConstants {
- public static final String NAMESPACE = "Orchestration";
- public static final String PROCESS_IMPL_KEY = "process_impl";
- private ConfigConstants(){
+ public static final String NAMESPACE = "Orchestration";
+ public static final String PROCESS_IMPL_KEY = "process_impl";
- }
+ private ConfigConstants() {
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResult.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResult.java
index bc24103779..5aca10294e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResult.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResult.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,29 +17,26 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types;
-
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
-
import java.util.Set;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
public class DeploymentFlavorValidationResult {
- private boolean valid;
- private Set<CompositionEntityValidationData> validationData;
- public DeploymentFlavorValidationResult(Set<CompositionEntityValidationData> validationData){
- this.validationData = validationData;
- valid = validationData == null;
- }
+ private boolean valid;
+ private Set<CompositionEntityValidationData> validationData;
- public boolean isValid() {
- return valid;
- }
+ public DeploymentFlavorValidationResult(Set<CompositionEntityValidationData> validationData) {
+ this.validationData = validationData;
+ valid = validationData == null;
+ }
- public Set<CompositionEntityValidationData> getValidationData() {
- return validationData;
- }
+ public boolean isValid() {
+ return valid;
+ }
+ public Set<CompositionEntityValidationData> getValidationData() {
+ return validationData;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/LicensingData.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/LicensingData.java
index e5b8f7ff66..5911701bea 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/LicensingData.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/LicensingData.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types;
import java.util.List;
@@ -27,22 +26,22 @@ import java.util.List;
*/
public class LicensingData {
- private String licenseAgreement;
- private List<String> featureGroups;
+ private String licenseAgreement;
+ private List<String> featureGroups;
- public String getLicenseAgreement() {
- return licenseAgreement;
- }
+ public String getLicenseAgreement() {
+ return licenseAgreement;
+ }
- public void setLicenseAgreement(String licenseAgreement) {
- this.licenseAgreement = licenseAgreement;
- }
+ public void setLicenseAgreement(String licenseAgreement) {
+ this.licenseAgreement = licenseAgreement;
+ }
- public List<String> getFeatureGroups() {
- return featureGroups;
- }
+ public List<String> getFeatureGroups() {
+ return featureGroups;
+ }
- public void setFeatureGroups(List<String> featureGroups) {
- this.featureGroups = featureGroups;
- }
+ public void setFeatureGroups(List<String> featureGroups) {
+ this.featureGroups = featureGroups;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ListComputeResponse.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ListComputeResponse.java
index 21e0de7f17..226f0aeede 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ListComputeResponse.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ListComputeResponse.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,32 +17,28 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
public class ListComputeResponse {
- private ComputeEntity computeEntity;
- private boolean associatedWithDeploymentFlavor;
-
- public boolean isAssociatedWithDeploymentFlavor() {
- return associatedWithDeploymentFlavor;
- }
-
- public void setAssociatedWithDeploymentFlavor(boolean associatedWithDeploymentFlavor) {
- this.associatedWithDeploymentFlavor = associatedWithDeploymentFlavor;
- }
+ private ComputeEntity computeEntity;
+ private boolean associatedWithDeploymentFlavor;
- public ComputeEntity getComputeEntity() {
- return computeEntity;
- }
+ public boolean isAssociatedWithDeploymentFlavor() {
+ return associatedWithDeploymentFlavor;
+ }
- public void setComputeEntity(
- ComputeEntity computeEntity) {
- this.computeEntity = computeEntity;
- }
+ public void setAssociatedWithDeploymentFlavor(boolean associatedWithDeploymentFlavor) {
+ this.associatedWithDeploymentFlavor = associatedWithDeploymentFlavor;
+ }
+ public ComputeEntity getComputeEntity() {
+ return computeEntity;
+ }
+ public void setComputeEntity(ComputeEntity computeEntity) {
+ this.computeEntity = computeEntity;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackage.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackage.java
index 1551cd8a1d..fc5306e892 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackage.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackage.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types;
import java.nio.ByteBuffer;
@@ -43,8 +42,7 @@ public class OnboardPackage {
this.fileContentHandler = fileContentHandler;
}
- public OnboardPackage(final String filename, final String fileExtension, final ByteBuffer fileContent)
- throws OnboardPackageException {
+ public OnboardPackage(final String filename, final String fileExtension, final ByteBuffer fileContent) throws OnboardPackageException {
this.filename = filename;
this.fileExtension = fileExtension;
this.fileContent = fileContent;
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackageInfo.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackageInfo.java
index 6c35bd67d9..a78185e89f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackageInfo.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackageInfo.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types;
import java.nio.ByteBuffer;
@@ -35,20 +34,17 @@ public class OnboardPackageInfo {
this(onboardPackage, onboardPackage, packageType);
}
- public OnboardPackageInfo(final OnboardPackage originalOnboardPackage,
- final OnboardPackage onboardPackage, final OnboardingTypesEnum packageType) {
+ public OnboardPackageInfo(final OnboardPackage originalOnboardPackage, final OnboardPackage onboardPackage,
+ final OnboardingTypesEnum packageType) {
this.packageType = packageType;
this.originalOnboardPackage = originalOnboardPackage;
this.onboardPackage = onboardPackage;
}
- public OnboardPackageInfo(final String filename,
- final String fileExtension,
- final ByteBuffer fileContent,
- final OnboardingTypesEnum packageType) throws OnboardPackageException {
+ public OnboardPackageInfo(final String filename, final String fileExtension, final ByteBuffer fileContent, final OnboardingTypesEnum packageType)
+ throws OnboardPackageException {
this.packageType = packageType;
originalOnboardPackage = new OnboardPackage(filename, fileExtension, fileContent);
this.onboardPackage = originalOnboardPackage;
}
-
-} \ No newline at end of file
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardSignedPackage.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardSignedPackage.java
index a1436fcd2d..e208610337 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardSignedPackage.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardSignedPackage.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types;
import java.nio.ByteBuffer;
@@ -27,13 +26,14 @@ import org.openecomp.core.utilities.file.FileContentHandler;
@Getter
public class OnboardSignedPackage extends OnboardPackage {
+
private String signatureFilePath;
private String internalPackageFilePath;
private String certificateFilePath;
public OnboardSignedPackage(final String filename, final String fileExtension, final ByteBuffer fileContent,
- final FileContentHandler fileContentHandler, final String signatureFilePath,
- final String internalPackageFilePath, final String certificateFilePath) {
+ final FileContentHandler fileContentHandler, final String signatureFilePath, final String internalPackageFilePath,
+ final String certificateFilePath) {
super(filename, fileExtension, fileContent, fileContentHandler);
this.signatureFilePath = signatureFilePath;
this.internalPackageFilePath = internalPackageFilePath;
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OrchestrationTemplateActionResponse.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OrchestrationTemplateActionResponse.java
index cca20351bd..bdda2a22bd 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OrchestrationTemplateActionResponse.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OrchestrationTemplateActionResponse.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,102 +17,95 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types;
-
-import org.apache.commons.collections4.CollectionUtils;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
public class OrchestrationTemplateActionResponse {
- private List<String> fileNames;
- private Map<String, List<ErrorMessage>> errors = new HashMap<>();
- private UploadFileStatus status = UploadFileStatus.Success;
- public UploadFileStatus getStatus() {
- return status;
- }
+ private List<String> fileNames;
+ private Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ private UploadFileStatus status = UploadFileStatus.Success;
- public void setStatus(UploadFileStatus status) {
- this.status = status;
- }
-
- public List<String> getFileNames() {
- return fileNames;
- }
-
- public void setFileNames(List<String> fileNames) {
- this.fileNames = fileNames;
- }
+ public UploadFileStatus getStatus() {
+ return status;
+ }
- public void addNewFileToList(String filename) {
- this.fileNames.add(filename);
- }
+ public void setStatus(UploadFileStatus status) {
+ this.status = status;
+ }
- public void removeFileFromList(String toRemove) {
- this.fileNames.remove(toRemove);
- }
+ public List<String> getFileNames() {
+ return fileNames;
+ }
- /**
- * Add structure errors.
- *
- * @param errorsByFileName the errors by file name
- */
- public void addStructureErrors(Map<String, List<ErrorMessage>> errorsByFileName) {
- if (errorsByFileName == null) {
- return;
+ public void setFileNames(List<String> fileNames) {
+ this.fileNames = fileNames;
}
- errors.putAll(errorsByFileName);
+ public void addNewFileToList(String filename) {
+ this.fileNames.add(filename);
+ }
- if (status == UploadFileStatus.Failure) {
- return;
+ public void removeFileFromList(String toRemove) {
+ this.fileNames.remove(toRemove);
}
- for (Map.Entry<String, List<ErrorMessage>> entry : errorsByFileName.entrySet()) {
- for (ErrorMessage errorMessage : entry.getValue()) {
- if (errorMessage.getLevel() == ErrorLevel.ERROR) {
- status = UploadFileStatus.Failure;
- return;
+
+ /**
+ * Add structure errors.
+ *
+ * @param errorsByFileName the errors by file name
+ */
+ public void addStructureErrors(Map<String, List<ErrorMessage>> errorsByFileName) {
+ if (errorsByFileName == null) {
+ return;
+ }
+ errors.putAll(errorsByFileName);
+ if (status == UploadFileStatus.Failure) {
+ return;
+ }
+ for (Map.Entry<String, List<ErrorMessage>> entry : errorsByFileName.entrySet()) {
+ for (ErrorMessage errorMessage : entry.getValue()) {
+ if (errorMessage.getLevel() == ErrorLevel.ERROR) {
+ status = UploadFileStatus.Failure;
+ return;
+ }
+ }
}
- }
}
- }
- /**
- * Add error message to map.
- *
- * @param key the key
- * @param error the error
- * @param level the level
- */
- public void addErrorMessageToMap(String key, String error, ErrorLevel level) {
- ErrorMessage errorMessage = new ErrorMessage(level, error);
- List<ErrorMessage> errorMessages = getErrorList(key);
-
- errorMessages.add(errorMessage);
- this.errors.put(key, errorMessages);
-
- if (level.equals(ErrorLevel.ERROR)) {
- status = UploadFileStatus.Failure;
+ /**
+ * Add error message to map.
+ *
+ * @param key the key
+ * @param error the error
+ * @param level the level
+ */
+ public void addErrorMessageToMap(String key, String error, ErrorLevel level) {
+ ErrorMessage errorMessage = new ErrorMessage(level, error);
+ List<ErrorMessage> errorMessages = getErrorList(key);
+ errorMessages.add(errorMessage);
+ this.errors.put(key, errorMessages);
+ if (level.equals(ErrorLevel.ERROR)) {
+ status = UploadFileStatus.Failure;
+ }
}
- }
- private List<ErrorMessage> getErrorList(String key) {
- List<ErrorMessage> errorMessages = this.errors.get(key);
- if (CollectionUtils.isEmpty(errorMessages)) {
- errorMessages = new ArrayList<>();
+ private List<ErrorMessage> getErrorList(String key) {
+ List<ErrorMessage> errorMessages = this.errors.get(key);
+ if (CollectionUtils.isEmpty(errorMessages)) {
+ errorMessages = new ArrayList<>();
+ }
+ return errorMessages;
}
- return errorMessages;
- }
-
- public Map<String, List<ErrorMessage>> getErrors() {
- return errors;
- }
+ public Map<String, List<ErrorMessage>> getErrors() {
+ return errors;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireResponse.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireResponse.java
index 3e7ef9f744..c0447c7cae 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireResponse.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireResponse.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,37 +17,37 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
public class QuestionnaireResponse {
- private String schema;
- private String data;
- private ErrorMessage errorMessage;
- public String getSchema() {
- return schema;
- }
+ private String schema;
+ private String data;
+ private ErrorMessage errorMessage;
+
+ public String getSchema() {
+ return schema;
+ }
- public void setSchema(String schema) {
- this.schema = schema;
- }
+ public void setSchema(String schema) {
+ this.schema = schema;
+ }
- public String getData() {
- return data;
- }
+ public String getData() {
+ return data;
+ }
- public void setData(String data) {
- this.data = data;
- }
+ public void setData(String data) {
+ this.data = data;
+ }
- public ErrorMessage getErrorMessage() {
- return errorMessage;
- }
+ public ErrorMessage getErrorMessage() {
+ return errorMessage;
+ }
- public void setErrorMessage(ErrorMessage errorMessage) {
- this.errorMessage = errorMessage;
- }
+ public void setErrorMessage(ErrorMessage errorMessage) {
+ this.errorMessage = errorMessage;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireValidationResult.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireValidationResult.java
index 2599d4723d..9f2e9bd2ec 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireValidationResult.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireValidationResult.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,27 +17,26 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
-
import java.util.Set;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
public class QuestionnaireValidationResult {
- private boolean valid;
- private Set<CompositionEntityValidationData> validationData;
- public QuestionnaireValidationResult(Set<CompositionEntityValidationData> validationData) {
- this.validationData = validationData;
- valid = validationData == null;
- }
+ private boolean valid;
+ private Set<CompositionEntityValidationData> validationData;
+
+ public QuestionnaireValidationResult(Set<CompositionEntityValidationData> validationData) {
+ this.validationData = validationData;
+ valid = validationData == null;
+ }
- public boolean isValid() {
- return valid;
- }
+ public boolean isValid() {
+ return valid;
+ }
- public Set<CompositionEntityValidationData> getValidationData() {
- return validationData;
- }
+ public Set<CompositionEntityValidationData> getValidationData() {
+ return validationData;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileResponse.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileResponse.java
index 31bdf21884..0456692b71 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileResponse.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileResponse.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,101 +17,97 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types;
-
-import org.apache.commons.collections4.MapUtils;
-import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.commons.collections4.MapUtils;
+import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
/**
* Created by TALIO on 4/27/2016.
*/
public class UploadFileResponse {
- private Map<String, List<ErrorMessage>> errors = new HashMap<>();
- private UploadFileStatus status = UploadFileStatus.Success;
- private OnboardingTypesEnum onboardingType;
- private String networkPackageName;
-
- public UploadFileStatus getStatus() {
- return status;
- }
-
- public void setStatus(UploadFileStatus status) {
- this.status = status;
- }
- public OnboardingTypesEnum getOnboardingType() {
- return onboardingType;
- }
+ private Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ private UploadFileStatus status = UploadFileStatus.Success;
+ private OnboardingTypesEnum onboardingType;
+ private String networkPackageName;
- public void setOnboardingType(OnboardingTypesEnum onboardingTypesEnum) {
- this.onboardingType = onboardingTypesEnum;
- }
-
- public String getNetworkPackageName() {
- return networkPackageName;
- }
+ public UploadFileStatus getStatus() {
+ return status;
+ }
- public void setNetworkPackageName(String networkPackageName) {
- this.networkPackageName = networkPackageName;
- }
+ public void setStatus(UploadFileStatus status) {
+ this.status = status;
+ }
- /**
- * Add structure error.
- *
- * @param fileName the file name
- * @param errorMessage the error message
- */
- public void addStructureError(String fileName, ErrorMessage errorMessage) {
- List<ErrorMessage> errorList = errors.get(fileName);
- if (errorList == null) {
- errorList = new ArrayList<>();
- errors.put(fileName, errorList);
+ public OnboardingTypesEnum getOnboardingType() {
+ return onboardingType;
}
- errorList.add(errorMessage);
- if (ErrorLevel.ERROR.equals(errorMessage.getLevel())) {
- status = UploadFileStatus.Failure;
+
+ public void setOnboardingType(OnboardingTypesEnum onboardingTypesEnum) {
+ this.onboardingType = onboardingTypesEnum;
}
- }
- /**
- * Add structure errors.
- *
- * @param errorsByFileName the errors by file name
- */
- public void addStructureErrors(Map<String, List<ErrorMessage>> errorsByFileName) {
- if (errorsByFileName == null) {
- return;
+ public String getNetworkPackageName() {
+ return networkPackageName;
}
- errors.putAll(errorsByFileName);
+ public void setNetworkPackageName(String networkPackageName) {
+ this.networkPackageName = networkPackageName;
+ }
- if (status == UploadFileStatus.Failure) {
- return;
+ /**
+ * Add structure error.
+ *
+ * @param fileName the file name
+ * @param errorMessage the error message
+ */
+ public void addStructureError(String fileName, ErrorMessage errorMessage) {
+ List<ErrorMessage> errorList = errors.get(fileName);
+ if (errorList == null) {
+ errorList = new ArrayList<>();
+ errors.put(fileName, errorList);
+ }
+ errorList.add(errorMessage);
+ if (ErrorLevel.ERROR.equals(errorMessage.getLevel())) {
+ status = UploadFileStatus.Failure;
+ }
}
- for (Map.Entry<String, List<ErrorMessage>> entry : errorsByFileName.entrySet()) {
- for (ErrorMessage errorMessage : entry.getValue()) {
- if (errorMessage.getLevel() == ErrorLevel.ERROR) {
- status = UploadFileStatus.Failure;
- return;
+
+ /**
+ * Add structure errors.
+ *
+ * @param errorsByFileName the errors by file name
+ */
+ public void addStructureErrors(Map<String, List<ErrorMessage>> errorsByFileName) {
+ if (errorsByFileName == null) {
+ return;
+ }
+ errors.putAll(errorsByFileName);
+ if (status == UploadFileStatus.Failure) {
+ return;
+ }
+ for (Map.Entry<String, List<ErrorMessage>> entry : errorsByFileName.entrySet()) {
+ for (ErrorMessage errorMessage : entry.getValue()) {
+ if (errorMessage.getLevel() == ErrorLevel.ERROR) {
+ status = UploadFileStatus.Failure;
+ return;
+ }
+ }
}
- }
}
- }
- public Map<String, List<ErrorMessage>> getErrors() {
- return errors;
- }
+ public Map<String, List<ErrorMessage>> getErrors() {
+ return errors;
+ }
- public boolean hasErrors() {
- return !MapUtils.isEmpty(errors);
- }
+ public boolean hasErrors() {
+ return !MapUtils.isEmpty(errors);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStatus.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStatus.java
index 2bd8d76a66..231111b0f9 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStatus.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStatus.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,10 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types;
public enum UploadFileStatus {
- Success,
- Failure
+ Success, Failure
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStructure.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStructure.java
index 525d627f4f..45a439fa61 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStructure.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStructure.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types;
import java.util.List;
@@ -27,17 +26,17 @@ import java.util.List;
*/
public class UploadFileStructure {
- private List<String> fileNames;
+ private List<String> fileNames;
- public List<String> getFileNames() {
- return fileNames;
- }
+ public List<String> getFileNames() {
+ return fileNames;
+ }
- public void setFileNames(List<String> fileNames) {
- this.fileNames = fileNames;
- }
+ public void setFileNames(List<String> fileNames) {
+ this.fileNames = fileNames;
+ }
- public void addNewFileToList(String filename) {
- this.fileNames.add(filename);
- }
+ public void addNewFileToList(String filename) {
+ this.fileNames.add(filename);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java
index cab205c212..4ec6027c26 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java
@@ -13,96 +13,92 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
import org.apache.commons.collections4.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.utils.VendorSoftwareProductUtils;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
public class ValidationResponse {
- private boolean valid = true;
- private Collection<ErrorCode> vspErrors;
- private Collection<ErrorCode> licensingDataErrors;
- private Map<String, List<ErrorMessage>> uploadDataErrors;
- private QuestionnaireValidationResult questionnaireValidationResult;
- public boolean isValid() {
- return valid;
- }
+ private boolean valid = true;
+ private Collection<ErrorCode> vspErrors;
+ private Collection<ErrorCode> licensingDataErrors;
+ private Map<String, List<ErrorMessage>> uploadDataErrors;
+ private QuestionnaireValidationResult questionnaireValidationResult;
- public Collection<ErrorCode> getVspErrors() {
- return vspErrors;
- }
-
- /**
- * Sets vsp errors.
- * @param vspErrors the vsp errors
- */
- public void setVspErrors(Collection<ErrorCode> vspErrors) {
- this.vspErrors = vspErrors;
- if (CollectionUtils.isNotEmpty(vspErrors)) {
- valid = false;
+ public boolean isValid() {
+ return valid;
}
- VendorSoftwareProductUtils.setErrorsIntoLogger(vspErrors);
- }
-
+ public Collection<ErrorCode> getVspErrors() {
+ return vspErrors;
+ }
- public Collection<ErrorCode> getLicensingDataErrors() {
- return licensingDataErrors;
- }
+ /**
+ * Sets vsp errors.
+ *
+ * @param vspErrors the vsp errors
+ */
+ public void setVspErrors(Collection<ErrorCode> vspErrors) {
+ this.vspErrors = vspErrors;
+ if (CollectionUtils.isNotEmpty(vspErrors)) {
+ valid = false;
+ }
+ VendorSoftwareProductUtils.setErrorsIntoLogger(vspErrors);
+ }
- /**
- * Sets licensing data errors.
- *
- * @param licensingDataErrors the licensing data errors
- */
- public void setLicensingDataErrors(Collection<ErrorCode> licensingDataErrors) {
- this.licensingDataErrors = licensingDataErrors;
- if (CollectionUtils.isNotEmpty(licensingDataErrors)) {
- valid = false;
+ public Collection<ErrorCode> getLicensingDataErrors() {
+ return licensingDataErrors;
}
- }
- public Map<String, List<ErrorMessage>> getUploadDataErrors() {
- return uploadDataErrors;
- }
+ /**
+ * Sets licensing data errors.
+ *
+ * @param licensingDataErrors the licensing data errors
+ */
+ public void setLicensingDataErrors(Collection<ErrorCode> licensingDataErrors) {
+ this.licensingDataErrors = licensingDataErrors;
+ if (CollectionUtils.isNotEmpty(licensingDataErrors)) {
+ valid = false;
+ }
+ }
- /**
- * Sets upload data errors.
- * @param uploadDataErrors the upload data errors
- */
- public void setUploadDataErrors(Map<String, List<ErrorMessage>> uploadDataErrors) {
- this.uploadDataErrors = uploadDataErrors;
- if (MapUtils.isNotEmpty(uploadDataErrors)) {
- valid = false;
+ public Map<String, List<ErrorMessage>> getUploadDataErrors() {
+ return uploadDataErrors;
}
- VendorSoftwareProductUtils
- .setErrorsIntoLogger(uploadDataErrors);
- }
+ /**
+ * Sets upload data errors.
+ *
+ * @param uploadDataErrors the upload data errors
+ */
+ public void setUploadDataErrors(Map<String, List<ErrorMessage>> uploadDataErrors) {
+ this.uploadDataErrors = uploadDataErrors;
+ if (MapUtils.isNotEmpty(uploadDataErrors)) {
+ valid = false;
+ }
+ VendorSoftwareProductUtils.setErrorsIntoLogger(uploadDataErrors);
+ }
- public QuestionnaireValidationResult getQuestionnaireValidationResult() {
- return questionnaireValidationResult;
- }
+ public QuestionnaireValidationResult getQuestionnaireValidationResult() {
+ return questionnaireValidationResult;
+ }
- /**
- * Sets questionnaire validation result.
- *
- * @param questionnaireValidationResult the questionnaire validation result
- */
- public void setQuestionnaireValidationResult(
- QuestionnaireValidationResult questionnaireValidationResult) {
- this.questionnaireValidationResult = questionnaireValidationResult;
- if (questionnaireValidationResult != null && !questionnaireValidationResult.isValid()) {
- valid = false;
+ /**
+ * Sets questionnaire validation result.
+ *
+ * @param questionnaireValidationResult the questionnaire validation result
+ */
+ public void setQuestionnaireValidationResult(QuestionnaireValidationResult questionnaireValidationResult) {
+ this.questionnaireValidationResult = questionnaireValidationResult;
+ if (questionnaireValidationResult != null && !questionnaireValidationResult.isValid()) {
+ valid = false;
+ }
}
- }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MonitoringUploadStatus.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MonitoringUploadStatus.java
index ad604e822e..ad6e5fb2ec 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MonitoringUploadStatus.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MonitoringUploadStatus.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,49 +17,44 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator;
public class MonitoringUploadStatus {
- private String snmpTrap;
- private String snmpPoll;
- private String vesEvent;
-
-
- //todo 1802 tech debt story : refactor this to be a map of type-filename
-
-
- public MonitoringUploadStatus(String snmpTrap, String snmpPoll) {
- this.snmpTrap = snmpTrap;
- this.snmpPoll = snmpPoll;
- }
- public MonitoringUploadStatus() {
- }
+ private String snmpTrap;
+ private String snmpPoll;
+ private String vesEvent;
- public String getSnmpTrap() {
- return snmpTrap;
- }
+ //todo 1802 tech debt story : refactor this to be a map of type-filename
+ public MonitoringUploadStatus(String snmpTrap, String snmpPoll) {
+ this.snmpTrap = snmpTrap;
+ this.snmpPoll = snmpPoll;
+ }
- public void setSnmpTrap(String snmpTrap) {
- this.snmpTrap = snmpTrap;
- }
+ public MonitoringUploadStatus() {
+ }
- public String getSnmpPoll() {
- return snmpPoll;
- }
+ public String getSnmpTrap() {
+ return snmpTrap;
+ }
- public String getVesEvent() {
- return vesEvent;
- }
+ public void setSnmpTrap(String snmpTrap) {
+ this.snmpTrap = snmpTrap;
+ }
- public void setVesEvent(String vesEvent) {
- this.vesEvent = vesEvent;
- }
+ public String getSnmpPoll() {
+ return snmpPoll;
+ }
- public void setSnmpPoll(String snmpPoll) {
- this.snmpPoll = snmpPoll;
+ public void setSnmpPoll(String snmpPoll) {
+ this.snmpPoll = snmpPoll;
+ }
+ public String getVesEvent() {
+ return vesEvent;
+ }
- }
+ public void setVesEvent(String vesEvent) {
+ this.vesEvent = vesEvent;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/zusammen/ItemProperties.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/zusammen/ItemProperties.java
index 03aad04e15..0bf3037e5b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/zusammen/ItemProperties.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/zusammen/ItemProperties.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.types.zusammen;
/**
@@ -21,12 +20,12 @@ package org.openecomp.sdc.vendorsoftwareproduct.types.zusammen;
* @since February 16, 2017
*/
public class ItemProperties {
- public static final String TYPE = "type";
- public static final String CATEGORY = "category";
- public static final String VENDOR_NAME = "vendorName";
- public static final String VSP_ID = "vspId";
- private ItemProperties(){
+ public static final String TYPE = "type";
+ public static final String CATEGORY = "category";
+ public static final String VENDOR_NAME = "vendorName";
+ public static final String VSP_ID = "vspId";
- }
+ private ItemProperties() {
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTracker.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTracker.java
index 39f04d67c6..8d6546f209 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTracker.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTracker.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.utils;
import java.util.HashMap;
@@ -22,51 +21,48 @@ import java.util.Map;
import java.util.Set;
public class ComponentDependencyTracker {
- private final Map<String, Set<String>> store = new HashMap<>();
- /**
- * Add dependency.
- *
- * @param dependent the dependent
- * @param dependsOn the depends on
- */
- public void addDependency(String dependent, String dependsOn) {
- if (dependent != null && dependsOn != null && dependent.trim().length() > 0 && dependsOn.trim()
- .length() > 0) {
- Set<String> dependsOnList = store
- .computeIfAbsent(dependent.toLowerCase(), k -> new HashSet<>());
- dependsOnList.add(dependsOn.toLowerCase());
- }
- }
+ private final Map<String, Set<String>> store = new HashMap<>();
- /**
- * Is cyclic dependency present boolean.
- *
- * @return the boolean
- */
- public boolean isCyclicDependencyPresent() {
- Set<Map.Entry<String, Set<String>>> entries = store.entrySet();
- for (Map.Entry<String, Set<String>> entry : entries) {
- for (String dependentOn : entry.getValue()) {
- if (!entry.getKey().equals(dependentOn) && isCyclicDependencyPresent(entry.getKey(),
- dependentOn)) {
- return true;
+ /**
+ * Add dependency.
+ *
+ * @param dependent the dependent
+ * @param dependsOn the depends on
+ */
+ public void addDependency(String dependent, String dependsOn) {
+ if (dependent != null && dependsOn != null && dependent.trim().length() > 0 && dependsOn.trim().length() > 0) {
+ Set<String> dependsOnList = store.computeIfAbsent(dependent.toLowerCase(), k -> new HashSet<>());
+ dependsOnList.add(dependsOn.toLowerCase());
}
- }
}
- return false;
- }
- private boolean isCyclicDependencyPresent(String root, String dependentOn) {
- Set<String> dependentOnList = store.get(dependentOn);
- if (dependentOnList != null && dependentOnList.contains(root)) {
- return true;
- } else if (dependentOnList != null) {
- for (String item : dependentOnList) {
- return isCyclicDependencyPresent(root, item);
- }
+ /**
+ * Is cyclic dependency present boolean.
+ *
+ * @return the boolean
+ */
+ public boolean isCyclicDependencyPresent() {
+ Set<Map.Entry<String, Set<String>>> entries = store.entrySet();
+ for (Map.Entry<String, Set<String>> entry : entries) {
+ for (String dependentOn : entry.getValue()) {
+ if (!entry.getKey().equals(dependentOn) && isCyclicDependencyPresent(entry.getKey(), dependentOn)) {
+ return true;
+ }
+ }
+ }
+ return false;
}
- return false;
- }
+ private boolean isCyclicDependencyPresent(String root, String dependentOn) {
+ Set<String> dependentOnList = store.get(dependentOn);
+ if (dependentOnList != null && dependentOnList.contains(root)) {
+ return true;
+ } else if (dependentOnList != null) {
+ for (String item : dependentOnList) {
+ return isCyclicDependencyPresent(root, item);
+ }
+ }
+ return false;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java
index ded0d3d2df..575c74d93c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java
@@ -13,9 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.utils;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.enrichment.types.MonitoringUploadType;
@@ -30,96 +35,84 @@ import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
-import java.io.File;
-import java.util.*;
-
public class VendorSoftwareProductUtils {
- private static final Logger LOGGER = LoggerFactory.getLogger(VendorSoftwareProductUtils.class);
-
- private VendorSoftwareProductUtils(){
-
- }
+ private static final Logger LOGGER = LoggerFactory.getLogger(VendorSoftwareProductUtils.class);
- /**
- * Add file names to upload file response.
- *
- * @param fileContentMap the file content map
- * @param uploadFileResponse the upload file response
- */
- public static void addFileNamesToUploadFileResponse(FileContentHandler fileContentMap,
- OrchestrationTemplateActionResponse uploadFileResponse) {
- uploadFileResponse.setFileNames(new ArrayList<>());
- for (String filename : fileContentMap.getFileList()) {
- if (!new File(filename).isDirectory()) {
- uploadFileResponse.addNewFileToList(filename);
- }
+ private VendorSoftwareProductUtils() {
}
- uploadFileResponse.removeFileFromList(SdcCommon.MANIFEST_NAME);
- }
- /**
- * Validate content zip data.
- *
- * @param contentMap the content map
- * @param errors the errors
- */
- public static void validateContentZipData(FileContentHandler contentMap,
- Map<String, List<ErrorMessage>> errors) {
- if (contentMap.getFileList().isEmpty()) {
- ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.UPLOAD_FILE, errors)
- .add(new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
- }
- }
-
-
- /**
- * Maps all artifacts by type.
- *
- * @param artifacts the artifacts
- * @return the map
- */
- public static Map<MonitoringUploadType, String> mapArtifactsByType(
- Collection<ComponentMonitoringUploadEntity> artifacts) {
- Map<MonitoringUploadType, String> artifactTypeToFilename
- = new EnumMap<>(MonitoringUploadType.class);
- for (ComponentMonitoringUploadEntity entity : artifacts) {
- artifactTypeToFilename.put(entity.getType(), entity.getArtifactName());
+ /**
+ * Add file names to upload file response.
+ *
+ * @param fileContentMap the file content map
+ * @param uploadFileResponse the upload file response
+ */
+ public static void addFileNamesToUploadFileResponse(FileContentHandler fileContentMap, OrchestrationTemplateActionResponse uploadFileResponse) {
+ uploadFileResponse.setFileNames(new ArrayList<>());
+ for (String filename : fileContentMap.getFileList()) {
+ if (!new File(filename).isDirectory()) {
+ uploadFileResponse.addNewFileToList(filename);
+ }
+ }
+ uploadFileResponse.removeFileFromList(SdcCommon.MANIFEST_NAME);
}
- return artifactTypeToFilename;
- }
-
-
- /**
- * Sets errors into logger.
- * @param errors the errors
- */
- public static void setErrorsIntoLogger(Map<String, List<ErrorMessage>> errors) {
- if (MapUtils.isEmpty(errors)) {
- return;
+ /**
+ * Validate content zip data.
+ *
+ * @param contentMap the content map
+ * @param errors the errors
+ */
+ public static void validateContentZipData(FileContentHandler contentMap, Map<String, List<ErrorMessage>> errors) {
+ if (contentMap.getFileList().isEmpty()) {
+ ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.UPLOAD_FILE, errors)
+ .add(new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
+ }
}
- for (Map.Entry<String, List<ErrorMessage>> listEntry : errors.entrySet()) {
- List<ErrorMessage> errorList = listEntry.getValue();
- for (ErrorMessage message : errorList) {
- LOGGER.error(message.getMessage());
- }
+ /**
+ * Maps all artifacts by type.
+ *
+ * @param artifacts the artifacts
+ * @return the map
+ */
+ public static Map<MonitoringUploadType, String> mapArtifactsByType(Collection<ComponentMonitoringUploadEntity> artifacts) {
+ Map<MonitoringUploadType, String> artifactTypeToFilename = new EnumMap<>(MonitoringUploadType.class);
+ for (ComponentMonitoringUploadEntity entity : artifacts) {
+ artifactTypeToFilename.put(entity.getType(), entity.getArtifactName());
+ }
+ return artifactTypeToFilename;
}
- }
-
- /**
- * Sets errors into logger.
- * @param errors the errors
- */
- public static void setErrorsIntoLogger(Collection<ErrorCode> errors) {
- if (CollectionUtils.isEmpty(errors)) {
- return;
+ /**
+ * Sets errors into logger.
+ *
+ * @param errors the errors
+ */
+ public static void setErrorsIntoLogger(Map<String, List<ErrorMessage>> errors) {
+ if (MapUtils.isEmpty(errors)) {
+ return;
+ }
+ for (Map.Entry<String, List<ErrorMessage>> listEntry : errors.entrySet()) {
+ List<ErrorMessage> errorList = listEntry.getValue();
+ for (ErrorMessage message : errorList) {
+ LOGGER.error(message.getMessage());
+ }
+ }
}
- for (ErrorCode error : errors) {
- LOGGER.error(error.message());
+ /**
+ * Sets errors into logger.
+ *
+ * @param errors the errors
+ */
+ public static void setErrorsIntoLogger(Collection<ErrorCode> errors) {
+ if (CollectionUtils.isEmpty(errors)) {
+ return;
+ }
+ for (ErrorCode error : errors) {
+ LOGGER.error(error.message());
+ }
}
- }
}