From 8e9c0653dd6c6862123c9609ae34e1206d86456e Mon Sep 17 00:00:00 2001 From: talig Date: Wed, 20 Dec 2017 14:30:43 +0200 Subject: Add collaboration feature Issue-ID: SDC-767 Change-Id: I14fb4c1f54086ed03a56a7ff7fab9ecd40381795 Signed-off-by: talig --- .../action/rest/ActionsForSwaggerFileUpload.java | 2 +- .../sdcrests/action/rest/services/ActionsImpl.java | 90 +++- .../activity-log-rest-services/pom.xml | 58 -- .../sdcrests/activitylog/rest/ActivityLog.java | 55 -- .../MapActivityLogEntityToActivityLogDto.java | 40 -- .../activitylog/rest/services/ActivityLogImpl.java | 65 --- .../activity-log-rest-types/pom.xml | 15 - .../sdcrests/activitylog/types/ActivityLogDto.java | 81 --- .../sdcrests/activitylog/types/ActivityStatus.java | 54 -- .../sdcrests/activitylog/types/ActivityType.java | 53 -- .../activity-log-rest/pom.xml | 22 - .../rest/ApplicationConfiguration.java | 2 +- .../services/ApplicationConfigurationImpl.java | 4 +- .../conflict-rest/conflict-rest-services/pom.xml | 58 ++ .../sdcrests/conflict/rest/Conflicts.java | 61 +++ .../rest/mapping/MapConflictInfoToDto.java | 14 + .../conflict/rest/mapping/MapConflictToDto.java | 134 +++++ .../rest/mapping/MapDtoToConflictResolution.java | 15 + .../rest/mapping/MapItemVersionConflictToDto.java | 22 + .../conflict/rest/services/ConflictsImpl.java | 62 +++ .../conflict-rest/conflict-rest-types/pom.xml | 22 + .../sdcrests/conflict/types/ConflictDto.java | 24 + .../sdcrests/conflict/types/ConflictInfoDto.java | 33 ++ .../conflict/types/ConflictResolutionDto.java | 27 + .../conflict/types/ItemVersionConflictDto.java | 29 + .../conflict-rest/pom.xml | 35 ++ .../sdcrests/health/rest/HealthCheck.java | 10 +- .../health/rest/services/HealthCheckImpl.java | 81 +-- .../item-permissions-rest-services/pom.xml | 68 +++ .../itempermissions/rest/ItemPermissions.java | 53 ++ .../MapItemPermissionsToItemPermissionsDto.java | 20 + .../rest/services/ItemPermissionsImpl.java | 52 ++ .../item-permissions-rest-types/pom.xml | 24 + .../itempermissions/types/ItemPermissionsDto.java | 27 + .../types/ItemPermissionsRequestDto.java | 32 ++ .../item-permissions-rest/pom.xml | 24 + .../item-rest/item-rest-services/pom.xml | 55 ++ .../org/openecomp/sdcrests/item/rest/Versions.java | 88 ++++ .../rest/mapping/MapActivityLogEntityToDto.java | 41 ++ .../sdcrests/item/rest/mapping/MapItemToDto.java | 15 + .../item/rest/mapping/MapRevisionToDto.java | 15 + .../item/rest/mapping/MapVersionToDto.java | 20 + .../sdcrests/item/rest/services/VersionsImpl.java | 270 ++++++++++ .../item-rest/item-rest-types/pom.xml | 34 ++ .../sdcrests/item/types/ActivityLogDto.java | 85 +++ .../sdcrests/item/types/ActivityStatus.java | 54 ++ .../sdcrests/item/types/CommitRequestDto.java | 13 + .../sdcrests/item/types/ItemCreationDto.java | 22 + .../org/openecomp/sdcrests/item/types/ItemDto.java | 40 ++ .../openecomp/sdcrests/item/types/RevisionDto.java | 43 ++ .../sdcrests/item/types/RevisionRequestDto.java | 14 + .../sdcrests/item/types/SubmitRequestDto.java | 13 + .../sdcrests/item/types/VersionAction.java | 28 + .../item/types/VersionActionRequestDto.java | 52 ++ .../openecomp/sdcrests/item/types/VersionDto.java | 94 ++++ .../sdcrests/item/types/VersionRequestDto.java | 24 + .../openecomp-sdc-rest-webapp/item-rest/pom.xml | 22 + .../notifications-fe/pom.xml | 161 ++++++ .../listeners/OnboardingAppStartupListener.java | 43 ++ .../src/main/resources/keyfile.txt | 27 + .../src/main/webapp/WEB-INF/beans-services.xml | 67 +++ .../src/main/webapp/WEB-INF/jetty-web.xml | 8 + .../main/webapp/WEB-INF/spring-mapper-servlet.xml | 12 + .../src/main/webapp/WEB-INF/web.xml | 81 +++ .../notifications-rest-services/pom.xml | 56 ++ .../rest/mapping/MapNotificationsStatusToDto.java | 64 +++ .../rest/mapping/MapNotificationsToDto.java | 57 ++ .../notifications/rest/services/Notifications.java | 94 ++++ .../rest/services/impl/NotificationsImpl.java | 117 +++++ .../notifications-rest-types/pom.xml | 23 + .../notifications/types/NotificationEntityDto.java | 91 ++++ .../types/NotificationResponseStatus.java | 26 + .../types/NotificationsStatusDto.java | 61 +++ .../types/UpdateNotificationResponseStatus.java | 65 +++ .../notifications-rest/pom.xml | 24 + .../onboarding-rest-war/pom.xml | 32 +- .../server/filters/ActionAuthenticationFilter.java | 6 +- .../server/filters/ActionAuthorizationFilter.java | 2 +- .../server/filters/SessionContextFilter.java | 45 ++ .../src/main/webapp/WEB-INF/beans-services.xml | 23 +- .../main/webapp/WEB-INF/spring-mapper-servlet.xml | 13 + .../src/main/webapp/WEB-INF/web.xml | 34 +- .../openecomp/sdcrests/common/RestConstants.java | 4 +- .../sdcrests/common/types/VersionDto.java | 34 -- .../openecomp/sdcrests/mapping/EchoMapMapping.java | 14 + .../openecomp/sdcrests/mapping/EchoMapping.java | 8 + .../openecomp/sdcrests/mapping/MappingBase.java | 6 - openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml | 6 +- .../sdcrests/validation/rest/Validation.java | 2 +- .../validation/rest/ValidationForSwaggerUsage.java | 2 +- .../validation/rest/services/ValidationImpl.java | 4 +- .../vendor-license-rest-services/pom.xml | 17 +- .../vendorlicense/rest/EntitlementPoolLimits.java | 46 +- .../sdcrests/vendorlicense/rest/FeatureGroups.java | 6 +- .../vendorlicense/rest/LicenseKeyGroupLimits.java | 33 +- .../vendorlicense/rest/VendorLicenseModels.java | 124 +++-- .../mapping/MapVendorLicenseModelEntityToDto.java | 36 ++ ...rLicenseModelToVendorLicenseModelEntityDto.java | 64 --- .../rest/services/EntitlementPoolLimitsImpl.java | 113 ++-- .../rest/services/EntitlementPoolsImpl.java | 20 +- .../rest/services/FeatureGroupsImpl.java | 16 +- .../rest/services/LicenseAgreementsImpl.java | 35 +- .../rest/services/LicenseKeyGroupLimitsImpl.java | 116 ++-- .../rest/services/LicenseKeyGroupsImpl.java | 16 +- .../rest/services/VendorLicenseModelsImpl.java | 348 ++++++++---- .../vendor-license-rest-types/pom.xml | 24 +- .../vendorlicense/types/FeatureGroupEntityDto.java | 2 +- .../types/LicenseAgreementEntityDto.java | 2 +- .../vendorlicense/types/MultiChoiceOrOtherDto.java | 2 +- .../types/VendorLicenseModelActionRequestDto.java | 21 +- .../types/VendorLicenseModelEntityDto.java | 49 -- .../sdcrests/vsp/rest/ComponentDependencies.java | 87 +++ .../vsp/rest/ComponentDependencyModels.java | 50 -- .../sdcrests/vsp/rest/ComponentProcesses.java | 10 +- .../org/openecomp/sdcrests/vsp/rest/Compute.java | 6 +- .../sdcrests/vsp/rest/DeploymentFlavors.java | 6 +- .../org/openecomp/sdcrests/vsp/rest/Images.java | 6 +- .../java/org/openecomp/sdcrests/vsp/rest/Nics.java | 6 +- .../vsp/rest/OrchestrationTemplateCandidate.java | 3 +- .../org/openecomp/sdcrests/vsp/rest/Processes.java | 6 +- .../sdcrests/vsp/rest/VendorSoftwareProducts.java | 36 +- ...VendorSoftwareProductsForSwaggerFileUpload.java | 7 +- .../openecomp/sdcrests/vsp/rest/VspEntities.java | 21 - .../MapComponentDependencyEntityToCreationDto.java | 16 + .../mapping/MapComponentDependencyEntityToDto.java | 18 + .../MapComputeDetailsDtoToComputeEntity.java | 2 +- .../rest/mapping/MapFilesDataStructureToDto.java | 17 + ...StructureToGetFileDataStructureResponseDto.java | 40 -- .../vsp/rest/mapping/MapImageDataToImageDto.java | 1 - .../vsp/rest/mapping/MapItemToVspDetailsDto.java | 18 + .../mapping/MapPackageInfoToPackageInfoDto.java | 2 +- .../MapQuestionnaireToQuestionnaireDto.java | 21 + .../rest/mapping/MapValidationResponseToDto.java | 33 +- ...edVendorSoftwareProductInfoToVspDetailsDto.java | 83 --- .../rest/mapping/MapVspDescriptionDtoToItem.java | 16 + .../mapping/MapVspDescriptionDtoToVspDetails.java | 13 +- .../vsp/rest/mapping/MapVspDetailsToDto.java | 53 ++ .../mapping/MapVspDetailsToVspCreationDto.java | 32 -- .../rest/services/ComponentDependenciesImpl.java | 119 +++++ .../services/ComponentDependencyModelsImpl.java | 78 --- .../services/ComponentMonitoringUploadsImpl.java | 23 +- .../vsp/rest/services/ComponentProcessesImpl.java | 77 ++- .../sdcrests/vsp/rest/services/ComponentsImpl.java | 45 +- .../sdcrests/vsp/rest/services/ComputeImpl.java | 88 ++-- .../vsp/rest/services/DeploymentFlavorsImpl.java | 43 +- .../sdcrests/vsp/rest/services/ImagesImpl.java | 85 ++- .../sdcrests/vsp/rest/services/NetworksImpl.java | 24 +- .../sdcrests/vsp/rest/services/NicsImpl.java | 60 ++- .../OrchestrationTemplateCandidateImpl.java | 71 ++- .../sdcrests/vsp/rest/services/ProcessesImpl.java | 36 +- .../rest/services/VendorSoftwareProductsImpl.java | 582 ++++++++++++++------- .../vsp/rest/services/VspItemProperty.java | 7 + .../vendor-software-products-rest-types/pom.xml | 5 + .../types/ComponentDependencyCreationDto.java | 13 + .../types/ComponentDependencyResponseDto.java | 41 ++ .../types/DeploymentFlavorRequestDto.java | 2 +- .../types/FileDataStructureDto.java | 69 +++ .../types/OnboardingMethod.java | 6 - .../types/QuestionnaireDto.java | 30 ++ .../types/VendorSoftwareProductAction.java | 3 - .../VersionSoftwareProductActionRequestDto.java | 11 + .../types/VspCreationDto.java | 36 -- .../types/VspDescriptionDto.java | 36 +- .../types/VspDetailsDto.java | 63 +-- .../types/VspRequestDto.java | 16 + .../types/validation/IsValidJson.java | 16 +- .../types/validation/StringValidator.java | 4 +- .../types/validation/ValidateString.java | 12 +- 168 files changed, 5144 insertions(+), 2078 deletions(-) delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/ActivityLog.java delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/mapping/MapActivityLogEntityToActivityLogDto.java delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/services/ActivityLogImpl.java delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/pom.xml delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityLogDto.java delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityStatus.java delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/Conflicts.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictInfoToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapDtoToConflictResolution.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/services/ConflictsImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictInfoDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictResolutionDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ItemVersionConflictDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/ItemPermissions.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/mapping/MapItemPermissionsToItemPermissionsDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Versions.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityLogDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityStatus.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/CommitRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemCreationDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/SubmitRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionAction.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionActionRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionRequestDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/resources/keyfile.txt create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/beans-services.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/jetty-web.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/spring-mapper-servlet.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/web.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/Notifications.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/impl/NotificationsImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationResponseStatus.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatus.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/SessionContextFilter.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/spring-mapper-servlet.xml delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/VersionDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapMapping.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapping.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelEntityToDto.java delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentDependencies.java delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentDependencyModels.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToCreationDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapFilesDataStructureToDto.java delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapFilesDataStructureToGetFileDataStructureResponseDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapItemToVspDetailsDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireToQuestionnaireDto.java delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToItem.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDetailsToDto.java delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDetailsToVspCreationDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentDependenciesImpl.java delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentDependencyModelsImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VspItemProperty.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyCreationDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyResponseDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/FileDataStructureDto.java delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OnboardingMethod.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireDto.java delete mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspRequestDto.java (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp') diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/ActionsForSwaggerFileUpload.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/ActionsForSwaggerFileUpload.java index 5dc79ebdfe..5a7232bdd6 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/ActionsForSwaggerFileUpload.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/ActionsForSwaggerFileUpload.java @@ -26,7 +26,6 @@ import io.swagger.annotations.ApiOperation; import org.apache.cxf.jaxrs.ext.multipart.Multipart; import org.springframework.validation.annotation.Validated; -import java.io.InputStream; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.Consumes; import javax.ws.rs.HeaderParam; @@ -38,6 +37,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.io.InputStream; @Path("/workflow/v1.0/actions") diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java index 875b51548e..b186852bfd 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java @@ -31,7 +31,11 @@ import org.openecomp.sdc.action.errors.ActionErrorConstants; import org.openecomp.sdc.action.errors.ActionException; import org.openecomp.sdc.action.logging.CategoryLogLevel; import org.openecomp.sdc.action.logging.StatusCode; -import org.openecomp.sdc.action.types.*; +import org.openecomp.sdc.action.types.Action; +import org.openecomp.sdc.action.types.ActionArtifact; +import org.openecomp.sdc.action.types.ActionArtifactProtection; +import org.openecomp.sdc.action.types.ActionRequest; +import org.openecomp.sdc.action.types.OpenEcompComponent; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdcrests.action.rest.Actions; @@ -53,11 +57,85 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.util.*; - -import static org.openecomp.sdc.action.ActionConstants.*; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.*; -import static org.openecomp.sdc.action.util.ActionUtil.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import static org.openecomp.sdc.action.ActionConstants.ACTION_REQUEST_PARAM_NAME; +import static org.openecomp.sdc.action.ActionConstants.ACTION_REQUEST_PARAM_SUPPORTED_MODELS; +import static org.openecomp.sdc.action.ActionConstants.ARTIFACT_FILE; +import static org.openecomp.sdc.action.ActionConstants.ARTIFACT_NAME; +import static org.openecomp.sdc.action.ActionConstants.BE_FQDN; +import static org.openecomp.sdc.action.ActionConstants.CATEGORY_LOG_LEVEL; +import static org.openecomp.sdc.action.ActionConstants.CLIENT_IP; +import static org.openecomp.sdc.action.ActionConstants.ERROR_DESCRIPTION; +import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_CATEGORY; +import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_MODEL; +import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NAME; +import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NONE; +import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_OPEN_ECOMP_COMPONENT; +import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_VENDOR; +import static org.openecomp.sdc.action.ActionConstants.INSTANCE_UUID; +import static org.openecomp.sdc.action.ActionConstants.LOCAL_ADDR; +import static org.openecomp.sdc.action.ActionConstants.MAX_ACTION_ARTIFACT_SIZE; +import static org.openecomp.sdc.action.ActionConstants.MDC_ASDC_INSTANCE_UUID; +import static org.openecomp.sdc.action.ActionConstants.PARTNER_NAME; +import static org.openecomp.sdc.action.ActionConstants.REMOTE_HOST; +import static org.openecomp.sdc.action.ActionConstants.REQUEST_EMPTY_BODY; +import static org.openecomp.sdc.action.ActionConstants.REQUEST_ID; +import static org.openecomp.sdc.action.ActionConstants.REQUEST_TYPE_CREATE_ACTION; +import static org.openecomp.sdc.action.ActionConstants.REQUEST_TYPE_UPDATE_ACTION; +import static org.openecomp.sdc.action.ActionConstants.REQUEST_TYPE_VERSION_ACTION; +import static org.openecomp.sdc.action.ActionConstants.SERVICE_INSTANCE_ID; +import static org.openecomp.sdc.action.ActionConstants.SERVICE_METRIC_BEGIN_TIMESTAMP; +import static org.openecomp.sdc.action.ActionConstants.SERVICE_NAME; +import static org.openecomp.sdc.action.ActionConstants.STATUS; +import static org.openecomp.sdc.action.ActionConstants.STATUS_CODE; +import static org.openecomp.sdc.action.ActionConstants.SUPPORTED_COMPONENTS_ID; +import static org.openecomp.sdc.action.ActionConstants.SUPPORTED_MODELS_VERSION_ID; +import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY; +import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY_API; +import static org.openecomp.sdc.action.ActionConstants.TARGET_SERVICE_NAME; +import static org.openecomp.sdc.action.ActionConstants.TIMESTAMP; +import static org.openecomp.sdc.action.ActionConstants.UPDATED_BY; +import static org.openecomp.sdc.action.ActionConstants.X_OPEN_ECOMP_INSTANCE_ID_HEADER_PARAM; +import static org.openecomp.sdc.action.ActionConstants.X_OPEN_ECOMP_REQUEST_ID_HEADER_PARAM; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_CHECKSUM_ERROR_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_NAME; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_NAME_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_PROTECTION_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_READ_FILE_ERROR; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_TOO_BIG_ERROR; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_TOO_BIG_ERROR_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_FILTER_MULTIPLE_QUERY_PARAM_NOT_SUPPORTED; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_INSTANCE_ID_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_PARAM_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_REQUEST_BODY_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_REQUEST_ID_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_SEARCH_CRITERIA; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_MULT_SEARCH_CRITERIA; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_ARTIFACT_CHECKSUM_ERROR; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_ARTIFACT_INVALID_PROTECTION_VALUE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_ARTIFACT_OPERATION_ALLOWED; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_BODY_EMPTY; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_CONTENT_TYPE_INVALID; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_FILTER_PARAM_INVALID; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_INVALID_GENERIC_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_INVALID_NAME; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_MISSING_MANDATORY_PARAM; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_OPEN_ECOMP_INSTANCE_ID_INVALID; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_OPEN_ECOMP_REQUEST_ID_INVALID; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UNSUPPORTED_OPERATION; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_CODE; +import static org.openecomp.sdc.action.util.ActionUtil.actionErrorLogProcessor; +import static org.openecomp.sdc.action.util.ActionUtil.actionLogPostProcessor; +import static org.openecomp.sdc.action.util.ActionUtil.getUtcDateStringFromTimestamp; /** * Implements various CRUD API that can be performed on Action diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml deleted file mode 100644 index 10685dbac0..0000000000 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - 4.0.0 - - activity-log-rest-services - - - org.openecomp.sdc - activity-log-rest - 1.2.0-SNAPSHOT - - - - - - - javax.ws.rs - javax.ws.rs-api - ${ws.rs.version} - - - org.springframework - spring-context - ${spring.framework.version} - - - javax.inject - javax.inject - 1 - - - org.openecomp.sdc - openecomp-sdc-activity-log-manager - ${project.version} - - - org.openecomp.sdc - activity-log-rest-types - ${project.version} - - - org.openecomp.sdc - openecomp-sdc-common-rest - ${project.version} - - - - org.apache.cxf - cxf-rt-frontend-jaxrs - ${cxf.version} - - - - - - diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/ActivityLog.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/ActivityLog.java deleted file mode 100644 index be4cc1bbf5..0000000000 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/ActivityLog.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdcrests.activitylog.rest; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import org.openecomp.sdcrests.activitylog.types.ActivityLogDto; -import org.springframework.validation.annotation.Validated; - -import javax.validation.constraints.NotNull; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - - -@Path("/v1.0/activity-logs") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -@Api(value = "Item Activity Log") -@Validated -public interface ActivityLog { - - @GET - @Path("/{itemId}/versions/{versionId}") - @ApiOperation(value = "List actions log of item", - response = ActivityLogDto.class, - responseContainer = "List") - Response getActivityLog(@ApiParam("Item Id") @PathParam("itemId") String itemId, - @ApiParam("Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); - -} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/mapping/MapActivityLogEntityToActivityLogDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/mapping/MapActivityLogEntityToActivityLogDto.java deleted file mode 100644 index 023dedf12c..0000000000 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/mapping/MapActivityLogEntityToActivityLogDto.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdcrests.activitylog.rest.mapping; - -import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; -import org.openecomp.sdcrests.activitylog.types.ActivityLogDto; -import org.openecomp.sdcrests.activitylog.types.ActivityStatus; -import org.openecomp.sdcrests.mapping.MappingBase; - -public class MapActivityLogEntityToActivityLogDto extends MappingBase { - - - @Override - public void doMapping(ActivityLogEntity source, ActivityLogDto target) { - target.setId(source.getId()); - target.setTimestamp(source.getTimestamp()); - target.setType(source.getType()); - target.setComment(source.getComment()); - target.setUser(source.getUser()); - target.setStatus(new ActivityStatus(source.isSuccess(), source.getMessage())); - } -} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/services/ActivityLogImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/services/ActivityLogImpl.java deleted file mode 100644 index c42d72b7a5..0000000000 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/services/ActivityLogImpl.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdcrests.activitylog.rest.services; - -import org.openecomp.sdc.activityLog.ActivityLogManager; -import org.openecomp.sdc.activityLog.ActivityLogManagerFactory; -import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; -import org.openecomp.sdc.logging.context.MdcUtil; -import org.openecomp.sdc.logging.types.LoggerServiceName; -import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdcrests.activitylog.rest.ActivityLog; -import org.openecomp.sdcrests.activitylog.rest.mapping.MapActivityLogEntityToActivityLogDto; -import org.openecomp.sdcrests.activitylog.types.ActivityLogDto; -import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Service; - -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - -@Named -@Service("activityLog") -@Scope(value = "prototype") -public class ActivityLogImpl implements ActivityLog { - - private ActivityLogManager activityLogManager = - ActivityLogManagerFactory.getInstance().createInterface(); - - - @Override - public Response getActivityLog(String vspId, String versionId, String user) { - MdcUtil.initMdc(LoggerServiceName.Get_List_Activity_Log.toString()); - - Collection activityLogs = - activityLogManager.listActivityLogs(vspId, Version.valueOf(versionId), user); - - MapActivityLogEntityToActivityLogDto mapper = new MapActivityLogEntityToActivityLogDto(); - GenericCollectionWrapper results = new GenericCollectionWrapper<>(); - for (ActivityLogEntity activityLog : activityLogs) { - results.add(mapper.applyMapping(activityLog, ActivityLogDto.class)); - } - - return Response.ok(results).build(); - } -} - diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/pom.xml deleted file mode 100644 index 70f029a0e3..0000000000 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/pom.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - 4.0.0 - - activity-log-rest-types - - - org.openecomp.sdc - activity-log-rest - 1.2.0-SNAPSHOT - - - diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityLogDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityLogDto.java deleted file mode 100644 index dde579554f..0000000000 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityLogDto.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdcrests.activitylog.types; - - - -import java.util.Date; - -public class ActivityLogDto { - - private String id; - private Date timestamp; - private String type; - private String comment; - private String user; - private ActivityStatus status; - - public ActivityLogDto(){} - - public String getId() { return id; } - - public void setId(String id) { this.id = id; } - - public Date getTimestamp() { - return timestamp; - } - - public void setTimestamp(Date timestamp) { - this.timestamp = timestamp; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getComment() { - return comment; - } - - public void setComment(String comment) { - this.comment = comment; - } - - public String getUser() { - return user; - } - - public void setUser(String user) { - this.user = user; - } - - public ActivityStatus getStatus() { - return status; - } - - public void setStatus(ActivityStatus status) { - this.status = status; - } -} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityStatus.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityStatus.java deleted file mode 100644 index 326b1b624d..0000000000 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityStatus.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.sdcrests.activitylog.types; - -public class ActivityStatus { - - private boolean success; - private String message; - - public ActivityStatus() { - } - - public ActivityStatus(boolean success) { - this(success, null); - } - - public ActivityStatus(boolean success, String message) { - this.success = success; - this.message = message; - } - - public boolean isSuccess() { - return success; - } - - public void setSuccess(boolean success) { - this.success = success; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java deleted file mode 100644 index 80160bc202..0000000000 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdcrests.activitylog.types; - -import java.io.Serializable; - -public enum ActivityType implements Serializable { - - CREATE_NEW("Create New"), - CHECKOUT("Check Out"), - UNDO_CHECKOUT("Undo Check Out"), - CHECKIN("Check In"), - UPLOAD_HEAT("Upload Heat"), - UPLOAD_MONITORING_FILE("Upload Monitoring File"), - SUBMIT("Submit"); - - // after collaboration will be added - this will be added: - /* - CREATE_NEW, - COMMIT, - ADD_PERMISSION, - REMOVE_PERMISSION, - */ - - private String name; - - ActivityType(String name) { - this.name = name; - } - - @Override - public String toString() { - return name; - } -} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml deleted file mode 100644 index 0b3c83c610..0000000000 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - 4.0.0 - - org.openecomp.sdc - activity-log-rest - pom - - - org.openecomp.sdc - openecomp-sdc-rest-webapp - 1.2.0-SNAPSHOT - - - - activity-log-rest-services - activity-log-rest-types - - - diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java index 6c95a14319..6042060480 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java @@ -26,7 +26,6 @@ import org.apache.cxf.jaxrs.ext.multipart.Multipart; import org.openecomp.sdcrests.applicationconfiguration.types.ConfigurationDataDto; import org.springframework.validation.annotation.Validated; -import java.io.InputStream; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -36,6 +35,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.io.InputStream; @Path("/v1.0/application-configuration") @Produces(MediaType.APPLICATION_JSON) diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java index c7f3f2598c..27557e1d56 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java @@ -38,10 +38,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import java.io.InputStream; -import java.util.Collection; import javax.inject.Named; import javax.ws.rs.core.Response; +import java.io.InputStream; +import java.util.Collection; /** * Created by Talio on 8/8/2016. diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/pom.xml new file mode 100644 index 0000000000..534aea1a73 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/pom.xml @@ -0,0 +1,58 @@ + + + 4.0.0 + + + org.openecomp.sdc + conflict-rest + 1.2.0-SNAPSHOT + + + conflict-rest-services + + + + + + + org.openecomp.sdc + openecomp-sdc-common-rest + ${project.version} + + + javax.inject + javax.inject + 1 + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + ${cxf.version} + + + org.openecomp.sdc + openecomp-sdc-conflict-manager + ${project.version} + + + org.openecomp.sdc + conflict-rest-types + ${project.version} + + + org.openecomp.sdc.onboarding + vendor-software-products-rest-services + ${project.version} + + + org.openecomp.sdc.onboarding + vendor-license-rest-services + ${project.version} + + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/Conflicts.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/Conflicts.java new file mode 100644 index 0000000000..396c4ee5d2 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/Conflicts.java @@ -0,0 +1,61 @@ +package org.openecomp.sdcrests.conflict.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdcrests.common.RestConstants; +import org.openecomp.sdcrests.conflict.types.ConflictDto; +import org.openecomp.sdcrests.conflict.types.ConflictResolutionDto; +import org.openecomp.sdcrests.conflict.types.ItemVersionConflictDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/v1.0/items/{itemId}/versions/{versionId}/conflicts") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Item Version Conflicts") +@Validated +public interface Conflicts { + + @GET + @Path("/") + @ApiOperation(value = "item version conflicts", + notes = "Item version private copy conflicts against its public copy", + response = ItemVersionConflictDto.class) + Response getConflict(@ApiParam("Item Id") @PathParam("itemId") String itemId, + @ApiParam("Version Id") @PathParam("versionId") String versionId, + @NotNull(message = RestConstants.USER_MISSING_ERROR_MSG) + @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/{conflictId}") + @ApiOperation(value = "Gets item version conflict", + notes = "Gets an item version private copy conflict against its public copy", + response = ConflictDto.class) + Response getConflict(@ApiParam("Item Id") @PathParam("itemId") String itemId, + @ApiParam("Version Id") @PathParam("versionId") String versionId, + @ApiParam("Version Id") @PathParam("conflictId") String conflictId, + @NotNull(message = RestConstants.USER_MISSING_ERROR_MSG) + @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{conflictId}") + @ApiOperation(value = "Resolves item version conflict", + notes = "Resolves an item version private copy conflict against its public copy") + Response resolveConflict(ConflictResolutionDto conflictResolution, + @ApiParam("Item Id") @PathParam("itemId") String itemId, + @ApiParam("Version Id") @PathParam("versionId") String versionId, + @ApiParam("Version Id") @PathParam("conflictId") String conflictId, + @NotNull(message = RestConstants.USER_MISSING_ERROR_MSG) + @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictInfoToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictInfoToDto.java new file mode 100644 index 0000000000..e80ef5653d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictInfoToDto.java @@ -0,0 +1,14 @@ +package org.openecomp.sdcrests.conflict.rest.mapping; + +import org.openecomp.conflicts.types.ConflictInfo; +import org.openecomp.sdcrests.conflict.types.ConflictInfoDto; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapConflictInfoToDto extends MappingBase { + @Override + public void doMapping(ConflictInfo source, ConflictInfoDto target) { + target.setId(source.getId()); + target.setType(source.getType()); + target.setName(source.getName()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDto.java new file mode 100644 index 0000000000..83a0f52155 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDto.java @@ -0,0 +1,134 @@ +package org.openecomp.sdcrests.conflict.rest.mapping; + +import org.openecomp.conflicts.types.Conflict; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.datatypes.model.ElementType; +import org.openecomp.sdcrests.conflict.types.ConflictDto; +import org.openecomp.sdcrests.mapping.EchoMapMapping; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapEntitlementPoolEntityToEntitlementPoolEntityDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapFeatureGroupEntityToFeatureGroupDescriptorDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLicenseAgreementEntityToLicenseAgreementDescriptorDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLimitEntityToLimitDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapVendorLicenseModelEntityToDto; +import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupDescriptorDto; +import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementDescriptorDto; +import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.FileDataStructureDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentDependencyModelEntityToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentEntityToComponentDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeEntityToVspComputeDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapDeploymentFlavorEntityToDeploymentFlavorDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapFilesDataStructureToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapImageEntityToImageDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNetworkEntityToNetworkDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNicEntityToNicDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapProcessEntityToProcessEntityDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireToQuestionnaireDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDetailsToDto; + +import java.util.AbstractMap; +import java.util.HashMap; +import java.util.Map; + +public class MapConflictToDto extends MappingBase { + + @Override + public void doMapping(Conflict source, ConflictDto target) { + target.setId(source.getId()); + target.setType(source.getType()); + target.setName(source.getName()); + + Map.Entry mapperToTargetClass = getMapper(source.getType()); + target.setTheirs(map(mapperToTargetClass, source.getTheirs())); + target.setYours(map(mapperToTargetClass, source.getYours())); + } + + private Map map(Map.Entry mapperToTargetClass, Object object) { + return JsonUtil + .json2Object(JsonUtil.object2Json( + mapperToTargetClass.getKey().applyMapping(object, mapperToTargetClass.getValue())), + Map.class); + } + + private Map.Entry getMapper(ElementType type) { + switch (type) { + case VendorLicenseModel: + return new AbstractMap.SimpleEntry<>(new MapVendorLicenseModelEntityToDto(), + VendorLicenseModelEntityDto.class); + case LicenseAgreement: + return new AbstractMap.SimpleEntry<>( + new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto(), + LicenseAgreementDescriptorDto.class); + case FeatureGroup: + return new AbstractMap.SimpleEntry<>(new MapFeatureGroupEntityToFeatureGroupDescriptorDto(), + FeatureGroupDescriptorDto.class); + case LicenseKeyGroup: + return new AbstractMap.SimpleEntry<>( + new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto(), LicenseKeyGroupEntityDto + .class); + case EntitlementPool: + return new AbstractMap.SimpleEntry<>( + new MapEntitlementPoolEntityToEntitlementPoolEntityDto(), EntitlementPoolEntityDto + .class); + case Limit: + return new AbstractMap.SimpleEntry<>(new MapLimitEntityToLimitDto(), LimitEntityDto.class); + case VendorSoftwareProduct: + return new AbstractMap.SimpleEntry<>(new MapVspDetailsToDto(), VspDetailsDto.class); + case Network: + return new AbstractMap.SimpleEntry<>(new MapNetworkEntityToNetworkDto(), NetworkDto.class); + case Component: + return new AbstractMap.SimpleEntry<>(new MapComponentEntityToComponentDto(), + ComponentDto.class); + case ComponentDependencies: + return new AbstractMap.SimpleEntry<>(new MapComponentDependencyModelEntityToDto(), + ComponentDependencyModel.class); + case Nic: + return new AbstractMap.SimpleEntry<>(new MapNicEntityToNicDto(), NicDto.class); + case Process: + return new AbstractMap.SimpleEntry<>(new MapProcessEntityToProcessEntityDto(), + ProcessEntityDto.class); + case DeploymentFlavor: + return new AbstractMap.SimpleEntry<>(new MapDeploymentFlavorEntityToDeploymentFlavorDto(), + DeploymentFlavorDto.class); + case Compute: + return new AbstractMap.SimpleEntry<>(new MapComputeEntityToVspComputeDto(), + VspComputeDto.class); + case Image: + return new AbstractMap.SimpleEntry<>(new MapImageEntityToImageDto(), ImageDto.class); + case VSPQuestionnaire: + case NicQuestionnaire: + case ComponentQuestionnaire: + case ImageQuestionnaire: + case ComputeQuestionnaire: + return new AbstractMap.SimpleEntry<>(new MapQuestionnaireToQuestionnaireDto(), + QuestionnaireDto.class); + case SNMP_POLL: + case SNMP_TRAP: + case VES_EVENTS: + case OrchestrationTemplateCandidate: + return new AbstractMap.SimpleEntry<>(new MapFilesDataStructureToDto(), + FileDataStructureDto.class); + case ServiceModel: + case NetworkPackage: + return new AbstractMap.SimpleEntry<>(new EchoMapMapping(), HashMap.class); + case itemVersion: + return new AbstractMap.SimpleEntry<>(new EchoMapMapping(), HashMap.class); + } + throw new RuntimeException("Get conflict does not support element type: " + type.name()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapDtoToConflictResolution.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapDtoToConflictResolution.java new file mode 100644 index 0000000000..1a03a6b15e --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapDtoToConflictResolution.java @@ -0,0 +1,15 @@ +package org.openecomp.sdcrests.conflict.rest.mapping; + +import org.openecomp.conflicts.types.ConflictResolution; +import org.openecomp.sdcrests.conflict.types.ConflictResolutionDto; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapDtoToConflictResolution + extends MappingBase { + + @Override + public void doMapping(ConflictResolutionDto source, ConflictResolution target) { + target.setResolution(source.getResolution()); + target.setOtherResolution(source.getOtherResolution()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDto.java new file mode 100644 index 0000000000..fb5d013aba --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDto.java @@ -0,0 +1,22 @@ +package org.openecomp.sdcrests.conflict.rest.mapping; + + +import org.openecomp.conflicts.types.ItemVersionConflict; +import org.openecomp.sdcrests.conflict.types.ConflictDto; +import org.openecomp.sdcrests.conflict.types.ConflictInfoDto; +import org.openecomp.sdcrests.conflict.types.ItemVersionConflictDto; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapItemVersionConflictToDto + extends MappingBase { + + @Override + public void doMapping(ItemVersionConflict source, ItemVersionConflictDto target) { + target + .setConflict(new MapConflictToDto().applyMapping(source.getVersionConflict(), ConflictDto.class)); + + MapConflictInfoToDto conflictInfoMapper = new MapConflictInfoToDto(); + source.getElementConflicts().forEach(conflictInfo -> target + .addConflictInfo(conflictInfoMapper.applyMapping(conflictInfo, ConflictInfoDto.class))); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/services/ConflictsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/services/ConflictsImpl.java new file mode 100644 index 0000000000..fda12ef4c6 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/services/ConflictsImpl.java @@ -0,0 +1,62 @@ +package org.openecomp.sdcrests.conflict.rest.services; + +import org.openecomp.conflicts.types.Conflict; +import org.openecomp.conflicts.types.ConflictResolution; +import org.openecomp.conflicts.types.ItemVersionConflict; +import org.openecomp.sdc.conflicts.ConflictsManager; +import org.openecomp.sdc.conflicts.ConflictsManagerFactory; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.conflict.rest.Conflicts; +import org.openecomp.sdcrests.conflict.rest.mapping.MapConflictToDto; +import org.openecomp.sdcrests.conflict.rest.mapping.MapDtoToConflictResolution; +import org.openecomp.sdcrests.conflict.rest.mapping.MapItemVersionConflictToDto; +import org.openecomp.sdcrests.conflict.types.ConflictDto; +import org.openecomp.sdcrests.conflict.types.ConflictResolutionDto; +import org.openecomp.sdcrests.conflict.types.ItemVersionConflictDto; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import javax.inject.Named; +import javax.ws.rs.core.Response; + +@Named +@Service("conflicts") +@Scope(value = "prototype") +public class ConflictsImpl implements Conflicts { + + @Override + public Response getConflict(String itemId, String versionId, String user) { + + ConflictsManager conflictsManager = ConflictsManagerFactory.getInstance().createInterface(); + ItemVersionConflict itemVersionConflict = conflictsManager.getConflict + (itemId, new Version(versionId)); + ItemVersionConflictDto result = (new MapItemVersionConflictToDto()).applyMapping + (itemVersionConflict, ItemVersionConflictDto.class); + return Response.ok(result).build(); + } + + @Override + public Response getConflict(String itemId, String versionId, String conflictId, String user) { + ConflictsManager conflictsManager = ConflictsManagerFactory.getInstance().createInterface(); + Conflict conflict = conflictsManager.getConflict(itemId, new Version(versionId), conflictId); + + ConflictDto result = new MapConflictToDto().applyMapping(conflict, ConflictDto.class); + + return Response.ok(result).build(); + + } + + @Override + public Response resolveConflict(ConflictResolutionDto conflictResolution, String itemId, + String versionId, String conflictId, String user) { + ConflictsManager conflictsManager = ConflictsManagerFactory.getInstance().createInterface(); + + Version version = new Version(versionId); + conflictsManager.resolveConflict(itemId, version, conflictId, + new MapDtoToConflictResolution() + .applyMapping(conflictResolution, ConflictResolution.class)); + conflictsManager.finalizeMerge(itemId, version); + + return Response.ok().build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/pom.xml new file mode 100644 index 0000000000..e0169332c8 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/pom.xml @@ -0,0 +1,22 @@ + + + 4.0.0 + + + org.openecomp.sdc + conflict-rest + 1.2.0-SNAPSHOT + + + conflict-rest-types + + + + org.openecomp.sdc + openecomp-sdc-conflict-manager + ${project.version} + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictDto.java new file mode 100644 index 0000000000..47f0abd794 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictDto.java @@ -0,0 +1,24 @@ +package org.openecomp.sdcrests.conflict.types; + +import java.util.Map; + +public class ConflictDto extends ConflictInfoDto { + private Map yours; + private Map theirs; + + public Map getYours() { + return yours; + } + + public void setYours(Map yours) { + this.yours = yours; + } + + public Map getTheirs() { + return theirs; + } + + public void setTheirs(Map theirs) { + this.theirs = theirs; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictInfoDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictInfoDto.java new file mode 100644 index 0000000000..e2e842a74e --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictInfoDto.java @@ -0,0 +1,33 @@ +package org.openecomp.sdcrests.conflict.types; + +import org.openecomp.sdc.datatypes.model.ElementType; + +public class ConflictInfoDto { + private String id; + private ElementType type; + private String name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ElementType getType() { + return type; + } + + public void setType(ElementType type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictResolutionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictResolutionDto.java new file mode 100644 index 0000000000..1aaf18f859 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictResolutionDto.java @@ -0,0 +1,27 @@ +package org.openecomp.sdcrests.conflict.types; + +import org.openecomp.conflicts.types.Resolution; + +import java.util.Map; + +public class ConflictResolutionDto { + private Resolution resolution; + // sits in lower level... + private Map otherResolution; + + public Resolution getResolution() { + return resolution; + } + + public void setResolution(Resolution resolution) { + this.resolution = resolution; + } + + public Map getOtherResolution() { + return otherResolution; + } + + public void setOtherResolution(Map otherResolution) { + this.otherResolution = otherResolution; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ItemVersionConflictDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ItemVersionConflictDto.java new file mode 100644 index 0000000000..3dbfcf03cf --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ItemVersionConflictDto.java @@ -0,0 +1,29 @@ +package org.openecomp.sdcrests.conflict.types; + +import java.util.ArrayList; +import java.util.Collection; + +public class ItemVersionConflictDto{ + private ConflictDto conflict; + private Collection conflictInfoList = new ArrayList<>(); + + public ConflictDto getConflict() { + return conflict; + } + + public void setConflict(ConflictDto conflict) { + this.conflict = conflict; + } + + public Collection getConflictInfoList() { + return conflictInfoList; + } + + public void setConflictInfoList(Collection conflictInfoList) { + this.conflictInfoList = conflictInfoList; + } + + public void addConflictInfo(ConflictInfoDto conflictInfo){ + conflictInfoList.add(conflictInfo); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/pom.xml new file mode 100644 index 0000000000..d29b22a680 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/pom.xml @@ -0,0 +1,35 @@ + + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-conflict-manager + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-common-rest + ${project.version} + + + + + org.openecomp.sdc + openecomp-sdc-rest-webapp + 1.2.0-SNAPSHOT + + + conflict-rest + + pom + + + + conflict-rest-services + conflict-rest-types + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java index 446a80e3cc..4be72a5999 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java @@ -39,10 +39,10 @@ import javax.ws.rs.core.Response; @Validated public interface HealthCheck { - @GET - @ApiOperation(value = "Perform health check", - response = HealthInfoDtos.class, - responseContainer = "List") - Response checkHealth( ); + @GET + @ApiOperation(value = "Perform health check", + response = HealthInfoDtos.class, + responseContainer = "List") + Response checkHealth(); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java index 38858c0e7c..5bdc034673 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java @@ -21,6 +21,7 @@ package org.openecomp.sdcrests.health.rest.services; import org.apache.cxf.jaxrs.impl.ResponseBuilderImpl; +import org.openecomp.sdc.common.session.SessionContextProviderFactory; import org.openecomp.sdc.health.HealthCheckManager; import org.openecomp.sdc.health.HealthCheckManagerFactory; import org.openecomp.sdc.health.data.HealthCheckResult; @@ -35,58 +36,60 @@ import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import java.util.Arrays; -import java.util.Collection; import javax.inject.Named; import javax.ws.rs.core.Response; +import java.util.Arrays; +import java.util.Collection; @Named @Service("healthCheck") @Scope(value = "prototype") public class HealthCheckImpl implements org.openecomp.sdcrests.health.rest.HealthCheck { - private HealthCheckManager healthCheckManager; - private static final Logger logger = LoggerFactory.getLogger(HealthCheckImpl.class); + private HealthCheckManager healthCheckManager; + private static final Logger logger = LoggerFactory.getLogger(HealthCheckImpl.class); - public HealthCheckImpl() { - try { - healthCheckManager = HealthCheckManagerFactory.getInstance().createInterface(); - } catch (Exception e){ - logger.error(e.getMessage(),e); - } + public HealthCheckImpl() { + try { + healthCheckManager = HealthCheckManagerFactory.getInstance().createInterface(); + } catch (Exception e) { + logger.error(e.getMessage(), e); } + } - @Override - public Response checkHealth() { - HealthCheckResult healthCheckResult = new HealthCheckResult(); + @Override + public Response checkHealth() { + HealthCheckResult healthCheckResult = new HealthCheckResult(); + SessionContextProviderFactory.getInstance().createInterface().create("public"); - try { - MdcUtil.initMdc(LoggerServiceName.Health_check.toString()); - Collection healthInfos = healthCheckManager.checkHealth(); - healthCheckResult.setComponentsInfo(healthInfos); - boolean someIsDown = healthInfos.stream() - .anyMatch(healthInfo -> healthInfo.getHealthCheckStatus().equals(HealthCheckStatus.DOWN)); - healthInfos.stream(). - filter(healthInfo -> healthInfo.getHealthCheckComponent() - .equals(org.openecomp.sdc.health.data.MonitoredModules.BE)). - findFirst().ifPresent(healthInfo -> healthCheckResult.setSdcVersion(healthInfo.getVersion())); - if (someIsDown) { - Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl(); - return responseBuilder.entity(healthCheckResult).status(500).build(); - } - return Response.ok(healthCheckResult).build(); - } catch (Exception ex) { - logger.error("Health check failed", ex); - Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl(); - GenericCollectionWrapper results = new GenericCollectionWrapper<>(); - HealthInfo healthInfo = new HealthInfo(org.openecomp.sdc.health.data.MonitoredModules.BE , - HealthCheckStatus.DOWN, - "", "Failed to perform Health Check"); - Collection healthInfos = Arrays.asList(healthInfo); - healthCheckResult.setComponentsInfo(healthInfos); - return responseBuilder.entity(healthCheckResult).status(500).build(); - } + try { + MdcUtil.initMdc(LoggerServiceName.Health_check.toString()); + Collection healthInfos = healthCheckManager.checkHealth(); + healthCheckResult.setComponentsInfo(healthInfos); + boolean someIsDown = healthInfos.stream() + .anyMatch(healthInfo -> healthInfo.getHealthCheckStatus().equals(HealthCheckStatus.DOWN)); + healthInfos.stream(). + filter(healthInfo -> healthInfo.getHealthCheckComponent() + .equals(org.openecomp.sdc.health.data.MonitoredModules.BE)). + findFirst() + .ifPresent(healthInfo -> healthCheckResult.setSdcVersion(healthInfo.getVersion())); + if (someIsDown) { + Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl(); + return responseBuilder.entity(healthCheckResult).status(500).build(); + } + return Response.ok(healthCheckResult).build(); + } catch (Exception ex) { + logger.error("Health check failed", ex); + Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl(); + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + HealthInfo healthInfo = new HealthInfo(org.openecomp.sdc.health.data.MonitoredModules.BE, + HealthCheckStatus.DOWN, + "", "Failed to perform Health Check"); + Collection healthInfos = Arrays.asList(healthInfo); + healthCheckResult.setComponentsInfo(healthInfos); + return responseBuilder.entity(healthCheckResult).status(500).build(); } + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/pom.xml new file mode 100644 index 0000000000..cec27da833 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/pom.xml @@ -0,0 +1,68 @@ + + + 4.0.0 + + + org.openecomp.sdc + item-permissions-rest + 1.2.0-SNAPSHOT + + + item-permissions-rest-services + + + + + + org.openecomp.sdc + item-permissions-rest-types + ${project.version} + + + + org.openecomp.sdc + openecomp-sdc-common-rest + ${project.version} + + + + org.openecomp.sdc + openecomp-sdc-item-permissions-manager + ${project.version} + + + + javax.inject + javax.inject + 1 + + + + + + + + + + + + + + + + + io.swagger + swagger-models + RELEASE + + + org.springframework + spring-context + ${spring.framework.version} + + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/ItemPermissions.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/ItemPermissions.java new file mode 100644 index 0000000000..e73595c67b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/ItemPermissions.java @@ -0,0 +1,53 @@ +package org.openecomp.sdcrests.itempermissions.rest; + + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsDto; +import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsRequestDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +/** + * Created by ayalaben on 6/18/2017. + */ +@Path("/v1.0/items/{itemId}/permissions") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Item Permissions") +@Validated +public interface ItemPermissions { + + @GET + @Path("/") + @ApiOperation(value = "List users permissions assigned on item", + response = ItemPermissionsDto.class, + responseContainer = "List") + + Response list(@PathParam("itemId") String itemId, + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{permission}") + @ApiOperation(value = "Update useres permission on item") + Response updatePermissions(@Valid ItemPermissionsRequestDto request, + @PathParam("itemId") String itemId, + @PathParam("permission") String permission, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/mapping/MapItemPermissionsToItemPermissionsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/mapping/MapItemPermissionsToItemPermissionsDto.java new file mode 100644 index 0000000000..88c3d4d74e --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/mapping/MapItemPermissionsToItemPermissionsDto.java @@ -0,0 +1,20 @@ +package org.openecomp.sdcrests.itempermissions.rest.mapping; + +import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity; +import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsDto; +import org.openecomp.sdcrests.mapping.MappingBase; + +/** + * Created by ayalaben on 6/18/2017. + */ + +public class MapItemPermissionsToItemPermissionsDto extends + MappingBase { + + + @Override + public void doMapping(ItemPermissionsEntity source, ItemPermissionsDto target) { + target.setUserId(source.getUserId()); + target.setPermission(source.getPermission()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java new file mode 100644 index 0000000000..4fe93c20ac --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java @@ -0,0 +1,52 @@ +//package org.openecomp.sdcrests.itempermissions.rest.mapping.mapping.services; +package org.openecomp.sdcrests.itempermissions.rest.services; + + +import org.openecomp.sdc.itempermissions.ItemPermissionsManager; +import org.openecomp.sdc.itempermissions.ItemPermissionsManagerFactory; +import org.openecomp.sdcrests.itempermissions.rest.ItemPermissions; +import org.openecomp.sdcrests.itempermissions.rest.mapping.MapItemPermissionsToItemPermissionsDto; +import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsDto; +import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsRequestDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import javax.inject.Named; +import javax.ws.rs.core.Response; + +/** + * Created by ayalaben on 6/18/2017. + */ + +@Named +@Service("itemPermissions") +@Scope(value = "prototype") +public class ItemPermissionsImpl implements ItemPermissions { + + private ItemPermissionsManager itemPermissionsManager = + ItemPermissionsManagerFactory.getInstance().createInterface(); + + @Override + public Response list(String itemId, String user) { + + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + MapItemPermissionsToItemPermissionsDto mapper = new MapItemPermissionsToItemPermissionsDto(); + + itemPermissionsManager.listItemPermissions(itemId) + .forEach(itemPermission -> results.add(mapper.applyMapping + (itemPermission, ItemPermissionsDto.class))); + + return Response.ok(results).build(); + } + + @Override + public Response updatePermissions(ItemPermissionsRequestDto request, String itemId, + String permission, String user) { + + itemPermissionsManager.updateItemPermissions(itemId,permission,request.getAddedUsersIds(), + request.getRemovedUsersIds()); + + return Response.ok().build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/pom.xml new file mode 100644 index 0000000000..49f1f2b6d3 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + + io.swagger + swagger-annotations + 1.5.3 + + + + + + org.openecomp.sdc + item-permissions-rest + 1.2.0-SNAPSHOT + + + item-permissions-rest-types + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDto.java new file mode 100644 index 0000000000..d7f0b9f259 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDto.java @@ -0,0 +1,27 @@ +package org.openecomp.sdcrests.itempermissions.types; + +/** + * Created by ayalaben on 6/18/2017. + */ +public class ItemPermissionsDto { + + private String userId; + private String permission; + + public String getUserId() { + return userId; + } + + public void setUserId(String id) { + this.userId = id; + } + + public String getPermission() { + return permission; + } + + public void setPermission(String permission) { + this.permission = permission; + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDto.java new file mode 100644 index 0000000000..82a960c7fd --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDto.java @@ -0,0 +1,32 @@ +package org.openecomp.sdcrests.itempermissions.types; + +import io.swagger.annotations.ApiModel; + +import java.util.Set; + +/** + * Created by ayalaben on 6/20/2017. + */ + +@ApiModel(value = "ItemPermissionsRequest") +public class ItemPermissionsRequestDto { + + private Set addedUsersIds; + private Set removedUsersIds; + + public Set getAddedUsersIds() { + return addedUsersIds; + } + + public void setAddedUsersIds(Set addedUsersIds) { + this.addedUsersIds = addedUsersIds; + } + + public Set getRemovedUsersIds() { + return removedUsersIds; + } + + public void setRemovedUsersIds(Set removedUsersIds) { + this.removedUsersIds = removedUsersIds; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/pom.xml new file mode 100644 index 0000000000..f89fb0760a --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-rest-webapp + 1.2.0-SNAPSHOT + + + org.openecomp.sdc + item-permissions-rest + + pom + + + + item-permissions-rest-types + item-permissions-rest-services + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/pom.xml new file mode 100644 index 0000000000..6b96a4d328 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + + + org.openecomp.sdc + item-rest + 1.2.0-SNAPSHOT + + + item-rest-services + + + + org.openecomp.sdc + openecomp-sdc-item-permissions-manager + ${project.version} + + + org.openecomp.sdc + item-rest-types + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-common-rest + ${project.version} + + + javax.inject + javax.inject + 1 + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + ${cxf.version} + + + org.openecomp.sdc + openecomp-sdc-conflict-manager + ${project.version} + + + org.springframework + spring-context + ${spring.framework.version} + + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Versions.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Versions.java new file mode 100644 index 0000000000..7d7b0854d9 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Versions.java @@ -0,0 +1,88 @@ +package org.openecomp.sdcrests.item.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdcrests.item.types.ActivityLogDto; +import org.openecomp.sdcrests.item.types.RevisionDto; +import org.openecomp.sdcrests.item.types.VersionActionRequestDto; +import org.openecomp.sdcrests.item.types.VersionDto; +import org.openecomp.sdcrests.item.types.VersionRequestDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +@Path("/v1.0/items/{itemId}/versions") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Item Versions") +@Validated +public interface Versions { + + @GET + @Path("/") + @ApiOperation(value = "Lists item versions", + response = VersionDto.class, + responseContainer = "List") + Response list(@PathParam("itemId") String itemId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @POST + @Path("/{versionId}") + @ApiOperation(value = "Creates a new item version") + Response create(VersionRequestDto request, + @PathParam("itemId") String itemId, + @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/{versionId}") + @ApiOperation(value = "Gets item version", response = VersionDto.class) + Response get(@PathParam("itemId") String itemId, + @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/{versionId}/activity-logs") + @ApiOperation(value = "Gets item version activity log", + response = ActivityLogDto.class, + responseContainer = "List") + Response getActivityLog(@ApiParam("Item Id") @PathParam("itemId") String itemId, + @ApiParam("Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/{versionId}/revisions") + @ApiOperation(value = "Gets item version revisions", response = RevisionDto.class, + responseContainer = "List") + Response listRevisions(@PathParam("itemId") String itemId, + @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{versionId}/actions") + @ApiOperation(value = "Acts on item version") + Response actOn(VersionActionRequestDto request, + @PathParam("itemId") String itemId, + @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDto.java new file mode 100644 index 0000000000..307b555720 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDto.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.item.rest.mapping; + +import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; +import org.openecomp.sdcrests.item.types.ActivityLogDto; +import org.openecomp.sdcrests.item.types.ActivityStatus; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapActivityLogEntityToDto + extends MappingBase { + + + @Override + public void doMapping(ActivityLogEntity source, ActivityLogDto target) { + target.setId(source.getId()); + target.setTimestamp(source.getTimestamp()); + target.setType(source.getType().name()); + target.setComment(source.getComment()); + target.setUser(source.getUser()); + target.setStatus(new ActivityStatus(source.isSuccess(), source.getMessage())); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDto.java new file mode 100644 index 0000000000..26bd58d950 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDto.java @@ -0,0 +1,15 @@ +package org.openecomp.sdcrests.item.rest.mapping; + +import org.openecomp.sdc.versioning.types.Item; +import org.openecomp.sdcrests.item.types.ItemDto; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapItemToDto extends MappingBase { + @Override + public void doMapping(Item source, ItemDto target) { + target.setId(source.getId()); + target.setType(source.getType()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDto.java new file mode 100644 index 0000000000..861f571c5f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDto.java @@ -0,0 +1,15 @@ +package org.openecomp.sdcrests.item.rest.mapping; + +import org.openecomp.sdc.versioning.dao.types.Revision; +import org.openecomp.sdcrests.item.types.RevisionDto; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapRevisionToDto extends MappingBase { + @Override + public void doMapping(Revision source, RevisionDto target) { + target.setId(source.getId()); + target.setMessage(source.getMessage()); + target.setUser(source.getUser()); + target.setTime(source.getTime()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDto.java new file mode 100644 index 0000000000..5fbd9a9e8d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDto.java @@ -0,0 +1,20 @@ +package org.openecomp.sdcrests.item.rest.mapping; + +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.item.types.VersionDto; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapVersionToDto extends MappingBase { + @Override + public void doMapping(Version source, VersionDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setBaseId(source.getBaseId()); + target.setStatus(source.getStatus()); + target.setState(source.getState()); + target.setCreationTime(source.getCreationTime()); + target.setModificationTime(source.getModificationTime()); + target.setAdditionalInfo(source.getAdditionalInfo()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java new file mode 100644 index 0000000000..466734208d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java @@ -0,0 +1,270 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.item.rest.services; + +import org.openecomp.sdc.activitylog.ActivityLogManager; +import org.openecomp.sdc.activitylog.ActivityLogManagerFactory; +import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; +import org.openecomp.sdc.activitylog.dao.type.ActivityType; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.Messages; +import org.openecomp.sdc.conflicts.ConflictsManager; +import org.openecomp.sdc.conflicts.ConflictsManagerFactory; +import org.openecomp.sdc.itempermissions.ItemPermissionsManager; +import org.openecomp.sdc.itempermissions.ItemPermissionsManagerFactory; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.notification.dtos.Event; +import org.openecomp.sdc.notification.factories.NotificationPropagationManagerFactory; +import org.openecomp.sdc.notification.services.NotificationPropagationManager; +import org.openecomp.sdc.versioning.ItemManager; +import org.openecomp.sdc.versioning.ItemManagerFactory; +import org.openecomp.sdc.versioning.VersioningManager; +import org.openecomp.sdc.versioning.VersioningManagerFactory; +import org.openecomp.sdc.versioning.dao.types.SynchronizationState; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.errors.RevisionIdNotFoundErrorBuilder; +import org.openecomp.sdc.versioning.types.NotificationEventTypes; +import org.openecomp.sdcrests.item.rest.Versions; +import org.openecomp.sdcrests.item.rest.mapping.MapActivityLogEntityToDto; +import org.openecomp.sdcrests.item.rest.mapping.MapRevisionToDto; +import org.openecomp.sdcrests.item.rest.mapping.MapVersionToDto; +import org.openecomp.sdcrests.item.types.ActivityLogDto; +import org.openecomp.sdcrests.item.types.CommitRequestDto; +import org.openecomp.sdcrests.item.types.RevisionDto; +import org.openecomp.sdcrests.item.types.RevisionRequestDto; +import org.openecomp.sdcrests.item.types.VersionActionRequestDto; +import org.openecomp.sdcrests.item.types.VersionDto; +import org.openecomp.sdcrests.item.types.VersionRequestDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import javax.inject.Named; +import javax.ws.rs.core.Response; +import java.util.HashMap; +import java.util.Map; + +import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBMIT_DESCRIPTION; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME; + +@Named +@Service("versions") +@Scope(value = "prototype") +public class VersionsImpl implements Versions { + + private static final String COMMIT_ITEM_ACTION = "Commit_Item"; + private static final Logger LOGGER = LoggerFactory.getLogger(VersionsImpl.class); + + private ItemPermissionsManager permissionsManager = + ItemPermissionsManagerFactory.getInstance().createInterface(); + private ItemManager itemManager = + ItemManagerFactory.getInstance().createInterface(); + private VersioningManager versioningManager = + VersioningManagerFactory.getInstance().createInterface(); + private ConflictsManager conflictsManager = + ConflictsManagerFactory.getInstance().createInterface(); + private ActivityLogManager activityLogManager = + ActivityLogManagerFactory.getInstance().createInterface(); + private NotificationPropagationManager notifier = + NotificationPropagationManagerFactory.getInstance().createInterface(); + + @Override + public Response list(String itemId, String user) { + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + MapVersionToDto mapper = new MapVersionToDto(); + + versioningManager.list(itemId) + .forEach(version -> results.add(mapper.applyMapping(version, VersionDto.class))); + return Response.ok(results).build(); + } + + @Override + public Response create(VersionRequestDto request, String itemId, String baseVersionId, + String user) { + Version version = new Version(); + version.setBaseId(baseVersionId); + version.setDescription(request.getDescription()); + + version = versioningManager.create(itemId, version, request.getCreationMethod()); + + VersionDto versionDto = new MapVersionToDto().applyMapping(version, VersionDto.class); + + activityLogManager.logActivity(new ActivityLogEntity(itemId, version, + ActivityType.Create_Version, user, true, "", "")); + + return Response.ok(versionDto).build(); + } + + @Override + public Response get(String itemId, String versionId, String user) { + Version version = getVersion(itemId, new Version(versionId)); + VersionDto versionDto = new MapVersionToDto().applyMapping(version, VersionDto.class); + return Response.ok(versionDto).build(); + } + + @Override + public Response getActivityLog(String itemId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_List_Activity_Log.toString()); + + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + MapActivityLogEntityToDto mapper = new MapActivityLogEntityToDto(); + + activityLogManager.listLoggedActivities(itemId, new Version(versionId)) + .forEach(loggedActivity -> results + .add(mapper.applyMapping(loggedActivity, ActivityLogDto.class))); + + return Response.ok(results).build(); + } + + @Override + public Response listRevisions(String itemId, String versionId, String user) { + GenericCollectionWrapper results = new GenericCollectionWrapper<>(); + MapRevisionToDto mapper = new MapRevisionToDto(); + + versioningManager.listRevisions(itemId, new Version(versionId)) + .forEach(revision -> results.add(mapper.applyMapping(revision, RevisionDto.class))); + return Response.ok(results).build(); + } + + @Override + public Response actOn(VersionActionRequestDto request, String itemId, String versionId, + String user) { + Version version = new Version(versionId); + switch (request.getAction()) { + case Sync: + sync(itemId, version); + break; + case Commit: + if (!permissionsManager.isAllowed(itemId, user, COMMIT_ITEM_ACTION)) { + return Response.status(Response.Status.FORBIDDEN) + .entity(new Exception(Messages.PERMISSIONS_ERROR.getErrorMessage())).build(); + } + commit(request.getCommitRequest(), itemId, version, user); + break; + case Revert: + revert(request.getRevisionRequest(), itemId, versionId); + break; + case Reset: + throw new UnsupportedOperationException("Action reset not supported."); + default: + } + return Response.ok().build(); + } + + + private void revert(RevisionRequestDto request, String itemId, String versionId) { + if (request.getRevisionId() == null) { + throw new CoreException(new RevisionIdNotFoundErrorBuilder().build()); + } + + versioningManager.revert(itemId, new Version(versionId), request.getRevisionId()); + } + + private void sync(String itemId, Version version) { + versioningManager.sync(itemId, version); + conflictsManager.finalizeMerge(itemId, version); + } + + private void commit(CommitRequestDto request, String itemId, Version version, String user) { + + String message = request == null ? "" : request.getMessage(); + + versioningManager.publish(itemId, version, message); + notifyUsers(itemId, version, message, user, NotificationEventTypes.COMMIT); + + activityLogManager.logActivity(new ActivityLogEntity(itemId, version, + ActivityType.Commit, user, true, "", message)); + } + + private void notifyUsers(String itemId, Version version, String message, + String userName, NotificationEventTypes eventType) { + Map eventProperties = new HashMap<>(); + eventProperties.put(ITEM_NAME, itemManager.get(itemId).getName()); + eventProperties.put(ITEM_ID, itemId); + + Version ver = versioningManager.get(itemId, version); + eventProperties.put(VERSION_NAME, ver.getName()); + eventProperties.put(VERSION_ID, ver.getId()); + + eventProperties.put(SUBMIT_DESCRIPTION, message); + eventProperties.put(PERMISSION_USER, userName); + + Event syncEvent = new SyncEvent(eventType.getEventName(), itemId, eventProperties, itemId); + try { + notifier.notifySubscribers(syncEvent, userName); + } catch (Exception e) { + LOGGER.error("Failed to send sync notification to users subscribed o item '" + itemId); + } + } + + private class SyncEvent implements Event { + + private String eventType; + private String originatorId; + private Map attributes; + private String entityId; + + public SyncEvent(String eventType, String originatorId, + Map 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 getAttributes() { + return attributes; + } + + @Override + public String getEntityId() { + return entityId; + } + } + + private Version getVersion(String itemId, Version version) { + version = versioningManager.get(itemId, version); + + if (version.getState().getSynchronizationState() != SynchronizationState.Merging && + conflictsManager.isConflicted(itemId, version)) { // looks for sdc applicative conflicts + version.getState().setSynchronizationState(SynchronizationState.Merging); + } + return version; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/pom.xml new file mode 100644 index 0000000000..6b974809b2 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + + org.openecomp.sdc + item-rest + 1.2.0-SNAPSHOT + + + item-rest-types + + + + org.openecomp.sdc + openecomp-sdc-versioning-api + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-activity-log-manager + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-conflict-manager + ${project.version} + + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityLogDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityLogDto.java new file mode 100644 index 0000000000..40fb91867e --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityLogDto.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.item.types; + + +import java.util.Date; + +public class ActivityLogDto { + + private String id; + private Date timestamp; + private String type; + private String comment; + private String user; + private ActivityStatus status; + + public ActivityLogDto() { + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Date getTimestamp() { + return timestamp; + } + + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public ActivityStatus getStatus() { + return status; + } + + public void setStatus(ActivityStatus status) { + this.status = status; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityStatus.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityStatus.java new file mode 100644 index 0000000000..601a211e5b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityStatus.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.sdcrests.item.types; + +public class ActivityStatus { + + private boolean success; + private String message; + + public ActivityStatus() { + } + + public ActivityStatus(boolean success) { + this(success, null); + } + + public ActivityStatus(boolean success, String message) { + this.success = success; + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/CommitRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/CommitRequestDto.java new file mode 100644 index 0000000000..a1d46cbdf1 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/CommitRequestDto.java @@ -0,0 +1,13 @@ +package org.openecomp.sdcrests.item.types; + +public class CommitRequestDto { + private String message; + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemCreationDto.java new file mode 100644 index 0000000000..afba96f6c8 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemCreationDto.java @@ -0,0 +1,22 @@ +package org.openecomp.sdcrests.item.types; + +public class ItemCreationDto { + private String itemId; + private VersionDto version; + + public String getItemId() { + return itemId; + } + + public void setItemId(String itemId) { + this.itemId = itemId; + } + + public VersionDto getVersion() { + return version; + } + + public void setVersion(VersionDto version) { + this.version = version; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemDto.java new file mode 100644 index 0000000000..1eebf19750 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemDto.java @@ -0,0 +1,40 @@ +package org.openecomp.sdcrests.item.types; + +public class ItemDto { + private String id; + private String type; + private String name; + private String description; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionDto.java new file mode 100644 index 0000000000..241d28541e --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionDto.java @@ -0,0 +1,43 @@ +package org.openecomp.sdcrests.item.types; + +import java.util.Date; + +public class RevisionDto { + private String id; + private String message; + private Date time; + private String user; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public void setMessage(String message) { + this.message = message; + } + + public void setTime(Date time) { + this.time = time; + } + + public String getMessage() { + return message; + } + + public Date getTime() { + return time; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionRequestDto.java new file mode 100644 index 0000000000..49ea9fc7f2 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionRequestDto.java @@ -0,0 +1,14 @@ +package org.openecomp.sdcrests.item.types; + +public class RevisionRequestDto { + + private String revisionId; + + public String getRevisionId() { + return revisionId; + } + + public void setRevisionId(String revisionId) { + this.revisionId = revisionId; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/SubmitRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/SubmitRequestDto.java new file mode 100644 index 0000000000..2591560fbb --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/SubmitRequestDto.java @@ -0,0 +1,13 @@ +package org.openecomp.sdcrests.item.types; + +public class SubmitRequestDto { + private String message; + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionAction.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionAction.java new file mode 100644 index 0000000000..c9d6f4e293 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionAction.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.item.types; + +public enum VersionAction { + Sync, + Commit, + Revert, + Reset +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionActionRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionActionRequestDto.java new file mode 100644 index 0000000000..98a5bb94ee --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionActionRequestDto.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.item.types; + +public class VersionActionRequestDto { + private VersionAction action; + private CommitRequestDto commitRequest; + + private RevisionRequestDto revisionRequest; + + public VersionAction getAction() { + return action; + } + + public void setAction(VersionAction action) { + this.action = action; + } + + public CommitRequestDto getCommitRequest() { + return commitRequest; + } + + public void setCommitRequest(CommitRequestDto commitRequest) { + this.commitRequest = commitRequest; + } + + public RevisionRequestDto getRevisionRequest() { + return revisionRequest; + } + + public void setRevisionRequest(RevisionRequestDto revisionRequest) { + this.revisionRequest = revisionRequest; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionDto.java new file mode 100644 index 0000000000..a0c1942b03 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionDto.java @@ -0,0 +1,94 @@ +package org.openecomp.sdcrests.item.types; + +import org.openecomp.sdc.versioning.dao.types.VersionState; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; + +import java.util.Date; +import java.util.Map; + +public class VersionDto { + private String id; + private String name; + private String description; + private String baseId; + private VersionStatus status; + private VersionState state; + private Date creationTime; + private Date modificationTime; + private Map additionalInfo; + public VersionDto() { + + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getBaseId() { + return baseId; + } + + public void setBaseId(String baseId) { + this.baseId = baseId; + } + + public VersionStatus getStatus() { + return status; + } + + public void setStatus(VersionStatus status) { + this.status = status; + } + + public VersionState getState() { + return state; + } + + public void setState(VersionState state) { + this.state = state; + } + + public Date getCreationTime() { + return creationTime; + } + + public void setCreationTime(Date creationTime) { + this.creationTime = creationTime; + } + + public Date getModificationTime() { + return modificationTime; + } + + public void setModificationTime(Date modificationTime) { + this.modificationTime = modificationTime; + } + + public Map getAdditionalInfo() { + return additionalInfo; + } + + public void setAdditionalInfo(Map additionalInfo) { + this.additionalInfo = additionalInfo; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionRequestDto.java new file mode 100644 index 0000000000..629bc2d2db --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionRequestDto.java @@ -0,0 +1,24 @@ +package org.openecomp.sdcrests.item.types; + +import org.openecomp.sdc.versioning.types.VersionCreationMethod; + +public class VersionRequestDto { + private String description; + private VersionCreationMethod creationMethod; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public VersionCreationMethod getCreationMethod() { + return creationMethod; + } + + public void setCreationMethod(VersionCreationMethod creationMethod) { + this.creationMethod = creationMethod; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/pom.xml new file mode 100644 index 0000000000..6623de8cce --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/pom.xml @@ -0,0 +1,22 @@ + + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-rest-webapp + 1.2.0-SNAPSHOT + + + item-rest + pom + + + + item-rest-services + item-rest-types + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml new file mode 100644 index 0000000000..319b0285cb --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml @@ -0,0 +1,161 @@ + + 4.0.0 + + org.openecomp.sdc.onboarding + notifications-fe + notification-war + war + + + org.openecomp.sdc + openecomp-sdc + ../../.. + 1.2.0-SNAPSHOT + + + + 4.3.4.RELEASE + 9.3.6.v20151106 + + + + + org.openecomp.sdc + openecomp-sdc-notification-websocket + ${project.version} + + + javax.servlet + servlet-api + ${javax.servlet.version} + + + + org.codehaus.jackson + jackson-jaxrs + ${org.codehaus.jackson.version} + + + org.codehaus.jackson + jackson-core-asl + ${org.codehaus.jackson.version} + + + javax.inject + javax.inject + 1 + + + org.eclipse.jetty + jetty-servlets + ${jetty.version} + + + + org.eclipse.jetty + jetty-util + ${jetty.version} + + + + javax.validation + validation-api + 1.0.0.GA + + + org.hibernate + hibernate-validator + 4.3.1.Final + + + javax.ws.rs + javax.ws.rs-api + 2.0.1 + + + org.codehaus.groovy + groovy + ${groovy.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + ch.qos.logback + logback-core + ${logback.version} + + + org.codehaus.janino + janino + compile + + + org.springframework + spring-context + ${spring.framework.version} + + + org.springframework + spring-core + ${spring.framework.version} + + + org.springframework + spring-web + ${spring.framework.version} + + + org.springframework + spring-aop + ${spring.framework.version} + + + org.springframework + spring-webmvc + ${spring.framework.version} + + + org.aspectj + aspectjweaver + 1.8.9 + + + org.aspectj + aspectjrt + 1.8.9 + + + org.aspectj + aspectjtools + 1.8.9 + + + org.apache.httpcomponents + httpclient + 4.3.6 + + + org.apache.cxf + cxf-rt-transports-http + 2.2.2 + + + + + + + + maven-war-plugin + 3.0.0 + + WEB-INF/lib/togglz*.jar + + + + + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java new file mode 100644 index 0000000000..96300b5cbb --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.server.listeners; + + +import org.springframework.web.context.ContextLoaderListener; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +public class OnboardingAppStartupListener implements ServletContextListener { + + ContextLoaderListener springListener; + + @Override + public void contextInitialized(ServletContextEvent servletContextEvent) { + springListener = new ContextLoaderListener(); + springListener.initWebApplicationContext(servletContextEvent.getServletContext()); + } + + @Override + public void contextDestroyed(ServletContextEvent servletContextEvent) { + springListener.closeWebApplicationContext(servletContextEvent.getServletContext()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/resources/keyfile.txt b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/resources/keyfile.txt new file mode 100644 index 0000000000..d6c2c253f8 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/resources/keyfile.txt @@ -0,0 +1,27 @@ +hfLSGGYWU2SyTlltV0HVwU6o3GtrtccAU8aFwq65OHsl6JeEAirXaNl73xz2uTrfiFqVJD7GTxXr +_qlY4BnLFZ7q3KNRZ0VQssjF_REjB8p7YMkEiTzbJL0pSaI6s0GRotuM432Jbsoksh8WZeui7svx +I_KD124t73d1EpIAQwHldZXRZEoDrLjfJUSCAcmsXSu5OlIMZDKOy7vR0aXPw6Dpn9sZBcpFHFQL +Xkp63yTf81snlVBGXApwS852_u4nEYmQrGQo9u6iLRg4dodOUD7wG7jbNB_KtmIspxL87i75hJ_0 +PXkLN8H2K14Rvk9ILYjdASpPOyVMK8avylRRyRy5HFBUJfeWk4YJEPus79Ol-j3QefWxX2hEOe_Y +AcA5xYgwsYylSARWcQ7aZ8M781-CNaM1yDkFCBRNLQoOo3k_yyspfHC0fOwIOPZdh9YiXIop3MAM +FC0SdPTUQrQxlF3IOC7tfEp7Wu2XezkcbIBe8mDy7dcYa87KqrL0zRju80R_gl-UCkxMLZpEKhnB +zWxjDNOGCC4VaLMrW6uREFlanw2yg3XAXZD2vl60r1WNUrRUJcYRs9FwNkdVhKH7o_D7GLXCxlEF +ltapyC4i1xgeXiEH35WrqlmS1PexaWkRloFmpLXY56D3iqg9RYrZnqQAift20LLQ_ZMFS_fOlb8w +pu-VqjifrOthE9B375Nq-_YdMCLRAdAXf5wiMC1AlimLE6gmE6cl0SopHpmtmLX--4jy8IUSOceG +xhTKpfO_7Gnn-V5m-ourtkj_UivEiM3eIyzilamlEtac50e-mg1sEHjPvAQd7p_oqaGd4NveSUeG +_WsLUZJgKI6Nu0545J1tDmlgZ4atd1b4Mkutl1CbijYg9c6Nu_zxMs9RwN9_-C3JJJxQpBUieXFY +f38PD62P8Ihb8VmNmBhOT8abRmH7Zx1adz6fcjFtaO0wSsfWr8M04W_GrbrGO_yr7GeJwqdYEP8r +rUoQWkNRuapL09KUHhHTdc8hQoCNUx4p2H2_ADA8j6gp62z54LUQDaTOHJI3Vs6mdfP7oDr2H_VK +LLWR7fHcDzS89opwtp7NO56jpmmq4q-U9kxpY1lMYJhKBuVMCm038l_eMGL35jD6OcgOCC2GL9U9 +wfyjwumJMNIND8I3viuyouMy_B5q00v27M2im6Q814Mg5Cw-RCiKy4kjhutkqTw8hXh7RLkm-QeJ +KlsrH98snwWLaw9LBeGoMbqzHzWl93inEsTyLutMPA8xSIj5kySLIcJCXq9-RMp8cnOYy8TY9Jix +oaB2u4ofHDDrrMzKY88ZPdMiGQX2BNdsOG6o4ifSVyyYwIWBtQvtO7SDvGhRUGEV1JHloBdIos0M +87SMERYd_UPKK_yl2RaqloQZRlDSgUR7i0hoqrhtPe5Ef4cJFX_CSt_oQnEu0JatwAuwybkLLPbO +mArd3rtrOh-uR_0Y77zb7Uw4H5_oX_ANIecH0sgRcvQESaq-ioYrvS94VqvxU8ByuxqxJLMo90Rc +oOAk3pq0b-16x_WRxWTfbnnNLDSQ_DwS-Xeav1nPwm-ELy1AVEQdpgbjONThjkZp3AuljaH_1Fs4 +u0A8HeCgIa4g7jsvIRxw6zLKspYENdvoHvQLWGRpaA-vfT3i3lR0MEu53v8M9hI8U8MqJo_J0xe6 +z2mtQWPiCLtW99vTqhKOm621_GNYmp10TEXVMkXumEk2rTgLBDaFEFwpgS5LqkEOObVChd9jx9oa +DW4LjhzO1EE5twGvbTiRAJsO6j5UNTonGFLLttYKq9CMvDiBZ8-whFGOM8D2qAWYiwDCI-dLqwat +jxQP1cYKGHMS2-VJ5QJa6EINEx2zo3VmnHYCE9gM71fC26018Y2T-sQfE1MRE9SU_Xma7Qbl5OBp +IflyJCTyhZfgFlqU9f2cq12bjoNuMrgOlKwap6325LGZK1XsmsHuHmASRE4-E-qmQY7GI9oJLmbl +425swlxRA-mr1eGZU0hK3ZFjz_4clBMLJBYMFYhdGzi4VYGPzaO0z0wNJzOQf3V5NbReFjxl \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/beans-services.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/beans-services.xml new file mode 100644 index 0000000000..c41bc03473 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/beans-services.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/jetty-web.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/jetty-web.xml new file mode 100644 index 0000000000..443b6a1fd3 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/jetty-web.xml @@ -0,0 +1,8 @@ + + + + + /notification-api + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/spring-mapper-servlet.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/spring-mapper-servlet.xml new file mode 100644 index 0000000000..2851d560ce --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/spring-mapper-servlet.xml @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/web.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..354fcbfac6 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,81 @@ + + + + + + contextConfigLocation + WEB-INF/beans-services.xml + + + + org.openecomp.server.listeners.OnboardingAppStartupListener + + + + cross-origin + org.eclipse.jetty.servlets.CrossOriginFilter + + allowedOrigins + * + + + allowedMethods + * + + + allowedHeaders + * + + + + cross-origin + /* + + + + spring-mapper + + org.springframework.web.servlet.DispatcherServlet + + 1 + + + + CXFServlet + CXF Servlet + + org.apache.cxf.transport.servlet.CXFServlet + + + redirects-list + + /docs/(\S)+\.json + + + + redirect-attributes + + javax.servlet.include.request_uri + + + + redirect-servlet-name + default + + 1 + + + + spring-mapper + /ws/* + + + CXFServlet + /* + + + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/pom.xml new file mode 100644 index 0000000000..597b017b0f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + + + org.openecomp.sdc + notifications-rest + 1.2.0-SNAPSHOT + + + notifications-rest-services + + + + org.openecomp.sdc + openecomp-sdc-application-config-manager + ${project.version} + provided + + + org.openecomp.sdc + openecomp-sdc-common-rest + ${project.version} + + + javax.inject + javax.inject + 1 + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + ${cxf.version} + + + org.openecomp.sdc + notifications-rest-types + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-notification-api + ${project.version} + + + org.springframework + spring-context + ${spring.framework.version} + + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java new file mode 100644 index 0000000000..41376b040f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.notifications.rest.mapping; + +import com.datastax.driver.core.utils.UUIDs; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.notification.dao.types.NotificationEntity; +import org.openecomp.sdc.notification.dtos.NotificationsStatus; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.notifications.types.NotificationEntityDto; +import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto; + +import java.text.DateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class MapNotificationsStatusToDto + extends MappingBase { + + private static final DateFormat formatter = + DateFormat.getDateTimeInstance(DateFormat.LONG, + DateFormat.SHORT); + + @Override + public void doMapping(NotificationsStatus source, NotificationsStatusDto target) { + + target.setLastScanned(source.getLastScanned()); + target.setNewEntries(source.getNewEntries()); + target.setEndOfPage(source.getEndOfPage()); + target.setNumOfNotSeenNotifications(source.getNumOfNotSeenNotifications()); + List entityDtos = new ArrayList<>(); + source.getNotifications() + .forEach(notification -> entityDtos.add(new NotificationEntityDto(notification.isRead(), + notification.getEventId(), notification.getEventType(), + JsonUtil.json2Object(notification.getEventAttributes(), Map.class), + extractDate(notification)))); + target.setNotifications(entityDtos); + } + + private String extractDate(NotificationEntity notification) { + return formatter.format(UUIDs.unixTimestamp + (notification + .getEventId())); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java new file mode 100644 index 0000000000..558453b7b6 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.notifications.rest.mapping; + +import com.datastax.driver.core.utils.UUIDs; +import org.apache.commons.collections4.CollectionUtils; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.notification.dao.types.NotificationEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.notifications.types.NotificationEntityDto; +import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto; + +import java.text.DateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class MapNotificationsToDto extends MappingBase, NotificationsStatusDto> { + private static final DateFormat formatter = + DateFormat.getDateTimeInstance(DateFormat.LONG, + DateFormat.SHORT); + @Override + public void doMapping(List source, NotificationsStatusDto target) { + List entityDtos = new ArrayList<>(); + if(CollectionUtils.isNotEmpty(source)) { + source.forEach(notification -> entityDtos.add(new NotificationEntityDto(notification.isRead(), + notification.getEventId(), notification.getEventType(), JsonUtil.json2Object(notification.getEventAttributes(), Map.class), + extractDate(notification)))); + target.setNotifications(entityDtos); + target.setLastScanned(source.get(0).getEventId()); + } + } + + private String extractDate(NotificationEntity notification) { + return formatter.format(UUIDs.unixTimestamp + (notification + .getEventId())); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/Notifications.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/Notifications.java new file mode 100644 index 0000000000..97199f604f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/Notifications.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.notifications.rest.services; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto; +import org.openecomp.sdcrests.notifications.types.UpdateNotificationResponseStatus; +import org.springframework.validation.annotation.Validated; + +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.lang.reflect.InvocationTargetException; +import java.util.UUID; + +import static org.openecomp.sdcrests.common.RestConstants.LAST_DELIVERED_QUERY_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +@Path("/v1.0/notifications") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Notifications") +@Validated +public interface Notifications { + String LIMIT_QUERY_PARAM = "NOTIFICATION_ROWS_LIMIT"; + String END_OF_PAGE_QUERY_PARAM = "END_OF_PAGE_EVENT_ID"; + + @GET + @ApiOperation(value = "Retrive all user notifications", + response = NotificationsStatusDto.class, + responseContainer = "List") + Response getNotifications( + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user, + @QueryParam(LAST_DELIVERED_QUERY_PARAM) UUID lastDelvered, + @QueryParam(END_OF_PAGE_QUERY_PARAM) UUID endOfPage); + + @PUT + @Path("/{notificationId}") + @ApiOperation(value = "Mark notification as read", + response = UpdateNotificationResponseStatus.class) + Response markAsRead( + @ApiParam(value = "Notification Id") @PathParam("notificationId") String notificationId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) + throws InvocationTargetException, IllegalAccessException; + + @PUT + @Path("/last-seen/{notificationId}") + @ApiOperation(value = "Update Last Seen Notification", + response = UpdateNotificationResponseStatus.class) + Response updateLastSeenNotification( + @ApiParam(value = "Notification Id") @PathParam("notificationId") String notificationId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) + throws InvocationTargetException, IllegalAccessException; + + @GET + @Path("/worker") + @ApiOperation(value = "Retrive user not delivered notifications", + response = NotificationsStatusDto.class, + responseContainer = "List") + Response getNewNotificationsByOwnerId( + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user, + @QueryParam(LAST_DELIVERED_QUERY_PARAM) String eventId, + @QueryParam(LIMIT_QUERY_PARAM) String limit); + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/impl/NotificationsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/impl/NotificationsImpl.java new file mode 100644 index 0000000000..8ff0ac0eea --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/impl/NotificationsImpl.java @@ -0,0 +1,117 @@ +package org.openecomp.sdcrests.notifications.rest.services.impl; + +import org.openecomp.sdc.common.errors.Messages; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.notification.dao.types.NotificationEntity; +import org.openecomp.sdc.notification.dtos.NotificationsStatus; +import org.openecomp.sdc.notification.exceptons.NotificationNotExistException; +import org.openecomp.sdc.notification.factories.NotificationsServiceFactory; +import org.openecomp.sdc.notification.services.NotificationsService; +import org.openecomp.sdcrests.notifications.rest.mapping.MapNotificationsStatusToDto; +import org.openecomp.sdcrests.notifications.rest.mapping.MapNotificationsToDto; +import org.openecomp.sdcrests.notifications.rest.services.Notifications; +import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto; +import org.openecomp.sdcrests.notifications.types.UpdateNotificationResponseStatus; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import javax.inject.Named; +import javax.ws.rs.core.Response; +import java.lang.reflect.InvocationTargetException; +import java.util.List; +import java.util.Objects; +import java.util.UUID; + +/** + * @author Avrahamg + * @since June 22, 2017 + */ +@Named +@Service("notifications") +@Scope(value = "prototype") +public class NotificationsImpl implements Notifications { + + private static int selectionLimit = 10; + + private static final Logger LOGGER = LoggerFactory.getLogger(NotificationsImpl.class); + private NotificationsService notificationsService = NotificationsServiceFactory.getInstance().createInterface(); + + @Override + public Response getNotifications(String user, UUID lastDelivered, UUID endOfPage) { + MdcUtil.initMdc(LoggerServiceName.notifications.toString()); + NotificationsStatus notificationsStatus = notificationsService + .getNotificationsStatus(user, lastDelivered, selectionLimit, endOfPage); + MapNotificationsStatusToDto converter = new MapNotificationsStatusToDto(); + NotificationsStatusDto notificationsStatusDto = new NotificationsStatusDto(); + converter.doMapping(notificationsStatus, notificationsStatusDto); + + return Response.ok(notificationsStatusDto).build(); + } + + @Override + public Response updateLastSeenNotification(String notificationId, String user) + throws InvocationTargetException, IllegalAccessException { + UpdateNotificationResponseStatus + updateNotificationResponseStatus = new UpdateNotificationResponseStatus(); + try { + notificationsService.updateLastSeenNotification(user, UUID.fromString(notificationId)); + } catch (Exception ex) { + LOGGER.error( + String.format(Messages.FAILED_TO_UPDATE_LAST_SEEN_NOTIFICATION.getErrorMessage(), + user), ex); + updateNotificationResponseStatus.addStructureError(notificationId, + new ErrorMessage(ErrorLevel.ERROR, + Messages.FAILED_TO_UPDATE_LAST_SEEN_NOTIFICATION.getErrorMessage())); + } + return Response.ok(updateNotificationResponseStatus).build(); + } + + @Override + public Response markAsRead(String notificationId, String user) + throws InvocationTargetException, IllegalAccessException { + + UpdateNotificationResponseStatus + updateNotificationResponseStatus = new UpdateNotificationResponseStatus(); + try { + notificationsService.markAsRead(user, notificationId); + } catch (NotificationNotExistException ex) { + LOGGER.error(Messages.FAILED_TO_MARK_NOTIFICATION_AS_READ.getErrorMessage(), ex); + updateNotificationResponseStatus.addStructureError( + notificationId, new ErrorMessage(ErrorLevel.ERROR, Messages + .FAILED_TO_MARK_NOTIFICATION_AS_READ + .getErrorMessage())); + } + return Response.ok(updateNotificationResponseStatus).build(); + } + + @Override + public Response getNewNotificationsByOwnerId(String user, String eventId, String limitStr) { + MdcUtil.initMdc(LoggerServiceName.notifications.toString()); + + int limit = selectionLimit; + + if (Objects.nonNull(limitStr)) { + try { + limit = Integer.parseInt(limitStr); + } + catch (NumberFormatException f) { + LOGGER.error("Non numeric selection list size value specified: " + limitStr); + } + } + + List notifications = Objects.isNull(eventId) + ? notificationsService.getNotificationsByOwnerId(user, limit) + : notificationsService.getNewNotificationsByOwnerId(user, UUID.fromString(eventId), limit); + + MapNotificationsToDto converter = new MapNotificationsToDto(); + NotificationsStatusDto notificationsStatusDto = new NotificationsStatusDto(); + converter.doMapping(notifications, notificationsStatusDto); + + return Response.ok(notificationsStatusDto).build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/pom.xml new file mode 100644 index 0000000000..4a3300ad12 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-datatypes-lib + ${project.version} + + + + + org.openecomp.sdc + notifications-rest + 1.2.0-SNAPSHOT + + + notifications-rest-types + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDto.java new file mode 100644 index 0000000000..d41deb3a4d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDto.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.notifications.types; + +import java.util.Map; +import java.util.UUID; + +public class NotificationEntityDto { + private boolean read; + private UUID eventId; + private String dateTime; + private String eventType; + private Map eventAttributes; + + public NotificationEntityDto() { + } + public NotificationEntityDto(boolean read, UUID eventId, String eventType, + Map eventAttributes) { + this.read = read; + this.eventId = eventId; + this.eventType = eventType; + this.eventAttributes = eventAttributes; + } + + public NotificationEntityDto(boolean read, UUID eventId,String eventType, + Map eventAttributes, String dateTime) { + this.read = read; + this.eventId = eventId; + this.dateTime = dateTime; + this.eventType = eventType; + this.eventAttributes = eventAttributes; + } + + public boolean isRead() { + return read; + } + + public void setRead(boolean read) { + this.read = read; + } + + public UUID getEventId() { + return eventId; + } + + public void setEventId(UUID eventId) { + this.eventId = eventId; + } + + public String getEventType() { + return eventType; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public Map getEventAttributes() { + return eventAttributes; + } + + public void setEventAttributes(Map eventAttributes) { + this.eventAttributes = eventAttributes; + } + + public String getDateTime() { + return dateTime; + } + + public void setDateTime(String dateTime) { + this.dateTime = dateTime; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationResponseStatus.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationResponseStatus.java new file mode 100644 index 0000000000..a0273d51e0 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationResponseStatus.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.notifications.types; + +public enum NotificationResponseStatus { + Success, + Failure +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDto.java new file mode 100644 index 0000000000..182245cc12 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDto.java @@ -0,0 +1,61 @@ +package org.openecomp.sdcrests.notifications.types; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +/** + * @author avrahamg + * @since June 29, 2017 + */ +public class NotificationsStatusDto { + private List notifications; + private List newEntries = new ArrayList<>(); + private UUID lastScanned; + private UUID endOfPage; + private long numOfNotSeenNotifications; + + public NotificationsStatusDto() { + } + + public List getNotifications() { + return notifications; + } + + public void setNotifications( + List notifications) { + this.notifications = notifications; + } + + public List getNewEntries() { + return newEntries; + } + + public void setNewEntries(List newEntries) { + this.newEntries = newEntries; + } + + public UUID getLastScanned() { + return lastScanned; + } + + public void setLastScanned(UUID lastScanned) { + this.lastScanned = lastScanned; + } + + public UUID getEndOfPage() { + return endOfPage; + } + + public void setEndOfPage(UUID endOfPage) { + this.endOfPage = endOfPage; + } + + public long getNumOfNotSeenNotifications() { + return numOfNotSeenNotifications; + } + + public void setNumOfNotSeenNotifications(long numOfNotSeenNotifications) { + this.numOfNotSeenNotifications = numOfNotSeenNotifications; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatus.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatus.java new file mode 100644 index 0000000000..9e985726dc --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatus.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.notifications.types; + +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 static org.openecomp.sdcrests.notifications.types.NotificationResponseStatus.Failure; +import static org.openecomp.sdcrests.notifications.types.NotificationResponseStatus.Success; + +/** + * Created by TALIO on 4/27/2016. + */ +public class UpdateNotificationResponseStatus { + private Map> errors = new HashMap<>(); + private NotificationResponseStatus status = Success; + + public Map> getErrors() { + return errors; + } + + public void setErrors(Map> errors) { + this.errors = errors; + } + + public NotificationResponseStatus getStatus() { + return status; + } + + public void setStatus(NotificationResponseStatus status) { + this.status = status; + } + + public void addStructureError(String notificationId, ErrorMessage errorMessage) { + List errorList = + errors.computeIfAbsent(notificationId, k -> new ArrayList<>()); + errorList.add(errorMessage); + if (ErrorLevel.ERROR.equals(errorMessage.getLevel())) { + status = Failure; + } + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/pom.xml new file mode 100644 index 0000000000..d35c5afbee --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-rest-webapp + 1.2.0-SNAPSHOT + + + org.openecomp.sdc + notifications-rest + + pom + + + + notifications-rest-types + notifications-rest-services + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml index 84c4eb408a..32975b3ebf 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml @@ -15,6 +15,11 @@ + + org.openecomp.sdc + item-rest-services + ${project.version} + org.openecomp.sdc.onboarding vendor-license-rest-services @@ -22,7 +27,12 @@ org.openecomp.sdc - activity-log-rest-services + openecomp-sdc-notification-api + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-notification-core ${project.version} @@ -40,6 +50,21 @@ healthcheck-rest-services ${project.version} + + org.openecomp.sdc + conflict-rest-services + ${project.version} + + + org.openecomp.sdc + item-permissions-rest-services + ${project.version} + + + org.openecomp.sdc + notifications-rest-services + ${project.version} + org.openecomp.sdc application-config-rest-services @@ -106,6 +131,11 @@ janino compile + + org.springframework + spring-context + ${spring.framework.version} + org.springframework spring-core diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java index 18465cd00c..e10f6a57ab 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java @@ -23,9 +23,6 @@ package org.openecomp.server.filters; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; -import java.io.IOException; -import java.security.Principal; -import java.util.Base64; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -35,6 +32,9 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.security.Principal; +import java.util.Base64; public class ActionAuthenticationFilter implements Filter { diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java index 82e4fa80d9..f54b06d46a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java @@ -20,7 +20,6 @@ package org.openecomp.server.filters; -import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -29,6 +28,7 @@ import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; public class ActionAuthorizationFilter implements Filter { diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/SessionContextFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/SessionContextFilter.java new file mode 100644 index 0000000000..b317fa6bf5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/SessionContextFilter.java @@ -0,0 +1,45 @@ +package org.openecomp.server.filters; + +import org.openecomp.sdc.common.session.SessionContextProvider; +import org.openecomp.sdc.common.session.SessionContextProviderFactory; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; + +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; + +public class SessionContextFilter implements Filter { + @Override + public void init(FilterConfig filterConfig) throws ServletException { + + } + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, + FilterChain filterChain) throws IOException, ServletException { + SessionContextProvider contextProvider = + SessionContextProviderFactory.getInstance().createInterface(); + + try { + if (servletRequest instanceof HttpServletRequest) { + String userName = ((HttpServletRequest) servletRequest).getHeader(USER_ID_HEADER_PARAM); + contextProvider.create(userName); + } + + filterChain.doFilter(servletRequest, servletResponse); + } finally { + contextProvider.close(); + } + } + + @Override + public void destroy() { + + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml index 8f4a2db73e..e43fa017d8 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml @@ -36,24 +36,14 @@ - - - - - + + + + @@ -75,9 +65,10 @@ - - + + + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/spring-mapper-servlet.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/spring-mapper-servlet.xml new file mode 100644 index 0000000000..437df7945f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/spring-mapper-servlet.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml index 35865f988e..de88197a8a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml @@ -22,6 +22,19 @@ org.openecomp.server.listeners.OnboardingAppStartupListener + + PermissionsFilter + org.openecomp.sdc.itempermissions.servlet.PermissionsFilter + + + PermissionsFilter + /v1.0/vendor-license-models/* + + + PermissionsFilter + /v1.0/vendor-software-products/* + + cross-origin org.eclipse.jetty.servlets.CrossOriginFilter @@ -68,6 +81,22 @@ LoggingServletFilter /* + + SessionContextFilter + org.openecomp.server.filters.SessionContextFilter + + + SessionContextFilter + /* + + + + spring-mapper + + org.springframework.web.servlet.DispatcherServlet + + 1 + CXFServlet @@ -94,7 +123,10 @@ 1 - + spring-mapper + /ws/* + + CXFServlet /* diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java index 7bc1082ebe..302af10dc2 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java @@ -21,10 +21,12 @@ package org.openecomp.sdcrests.common; public class RestConstants { - public static final String USER_ID_HEADER_PARAM = "USER_ID"; // value Should be equal to com.tlv.sdc.common.api.Constants#USER_ID_HEADER + public static final String USER_ID_HEADER_PARAM = "USER_ID"; + public static final String LAST_DELIVERED_QUERY_PARAM = "LAST_DELIVERED_EVENT_ID"; public static final String USER_MISSING_ERROR_MSG = "Field does not conform to predefined criteria : user : may not be null"; + public static final String INVALID_JSON_ERROR_MESSAGE = "Field does not conform to predefined criteria : body :must be in JSON format"; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/VersionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/VersionDto.java deleted file mode 100644 index b5b86c65a2..0000000000 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/VersionDto.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.openecomp.sdcrests.common.types; - -/** - * Created by SVISHNEV on 3/5/2017. - */ -public class VersionDto { - String id; - String label; - - public VersionDto(){ - - } - - public VersionDto(String id, String label) { - this.id = id; - this.label = label; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } -} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapMapping.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapMapping.java new file mode 100644 index 0000000000..81c2f37a66 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapMapping.java @@ -0,0 +1,14 @@ +package org.openecomp.sdcrests.mapping; + +import java.util.HashMap; + +/** + * Created by ayalaben on 9/12/2017 + */ +public class EchoMapMapping extends MappingBase,HashMap> { + + @Override +public void doMapping(HashMap source, HashMap target) { + target.putAll(source); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapping.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapping.java new file mode 100644 index 0000000000..4e5a22e3c7 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapping.java @@ -0,0 +1,8 @@ +package org.openecomp.sdcrests.mapping; + +public class EchoMapping extends MappingBase { + @Override + public void doMapping(Object source, Object target) { + target = source; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java index 2310c0f6ce..25c2be9158 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java @@ -23,15 +23,11 @@ package org.openecomp.sdcrests.mapping; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; -import org.openecomp.sdc.common.errors.Messages; import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; import org.openecomp.sdc.logging.types.LoggerConstants; import org.openecomp.sdc.logging.types.LoggerServiceName; -import org.openecomp.sdc.logging.api.Logger; -import org.openecomp.sdc.logging.api.LoggerFactory; - /** * Base class for all mapping classes. Mapping classes will perform data mapping from source object * to target object Base class provides following
  1. provides life cycle of @@ -55,8 +51,6 @@ public abstract class MappingBase { * @return T - instance of type T */ - private final Logger logger = (Logger) LoggerFactory.getLogger(this.getClass().getName()); - public final T applyMapping(final S source, Class clazz) { T target = (T) instantiateTarget(clazz); if (source == null || target == null) { diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml index 9970dfbdfd..d44e0c8b98 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml @@ -22,8 +22,12 @@ /validation-rest /action-library-rest /application-config-rest - /activity-log-rest /healthcheck-rest + conflict-rest + item-permissions-rest + item-rest + notifications-fe + notifications-rest diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/Validation.java b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/Validation.java index b08bc10727..349f0bdecf 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/Validation.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/Validation.java @@ -24,7 +24,6 @@ import io.swagger.annotations.Api; import org.apache.cxf.jaxrs.ext.multipart.Multipart; import org.springframework.validation.annotation.Validated; -import java.io.InputStream; import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -32,6 +31,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.io.InputStream; @Path("/v1.0/validation") diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/ValidationForSwaggerUsage.java b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/ValidationForSwaggerUsage.java index fd5bea3380..399f665655 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/ValidationForSwaggerUsage.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/ValidationForSwaggerUsage.java @@ -25,7 +25,6 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.validation.annotation.Validated; -import java.io.InputStream; import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -33,6 +32,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.io.InputStream; @Path("/v1.0/validation") diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/services/ValidationImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/services/ValidationImpl.java index 15675f14de..f43ff60b9f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/services/ValidationImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/services/ValidationImpl.java @@ -39,10 +39,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import java.io.IOException; -import java.io.InputStream; import javax.inject.Named; import javax.ws.rs.core.Response; +import java.io.IOException; +import java.io.InputStream; @Named @Service("validation") diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml index 643addc0aa..cec09f0e8f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml @@ -30,13 +30,13 @@ org.openecomp.sdc - openecomp-sdc-vendor-license-manager + openecomp-sdc-item-permissions-manager ${project.version} - + @@ -79,11 +79,11 @@ ${http.client.version} - +