From bcd42e7ec13f3a4cd83a2fdf57c0bfc4c0437824 Mon Sep 17 00:00:00 2001 From: amentis Date: Fri, 15 Dec 2023 10:15:00 +0200 Subject: [PATCH] change exception for confirm notifications requests --- .../java/eu/eudat/audit/AuditableAction.java | 4 ++++ ...tificationIntegrationEventHandlerImpl.java | 2 +- .../description/DescriptionServiceImpl.java | 4 ++-- .../eu/eudat/service/dmp/DmpServiceImpl.java | 10 ++++---- .../eudat/controllers/v2/UserController.java | 24 +++++++++---------- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java b/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java index f96d23464..25fe23812 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java +++ b/dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java @@ -81,6 +81,10 @@ public class AuditableAction { public static final EventId User_LanguageMine = new EventId(11007, "User_LanguageMine"); public static final EventId User_TimezoneMine = new EventId(11008, "User_TimezoneMine"); public static final EventId User_CultureMine = new EventId(11009, "User_CultureMine"); + public static final EventId User_MergeRequest = new EventId(11010, "User_MergeRequest"); + public static final EventId User_MergeConfirm = new EventId(11011, "User_MergeConfirm"); + public static final EventId User_RemoveCredentialRequest = new EventId(11012, "User_RemoveCredentialRequest"); + public static final EventId User_RemoveCredentialConfirm = new EventId(11013, "User_RemoveCredentialConfirm"); public static final EventId Tenant_Query = new EventId(12000, "Tenant_Query"); public static final EventId Tenant_Lookup = new EventId(12001, "Tenant_Lookup"); diff --git a/dmp-backend/core/src/main/java/eu/eudat/integrationevent/outbox/notification/NotificationIntegrationEventHandlerImpl.java b/dmp-backend/core/src/main/java/eu/eudat/integrationevent/outbox/notification/NotificationIntegrationEventHandlerImpl.java index 130d6b20d..9474f0a27 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/integrationevent/outbox/notification/NotificationIntegrationEventHandlerImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/integrationevent/outbox/notification/NotificationIntegrationEventHandlerImpl.java @@ -75,7 +75,7 @@ public class NotificationIntegrationEventHandlerImpl implements NotificationInte persist.setTrackingData(null); persist.setProvenanceRef(event.getProvenanceRef()); persist.setNotifiedAt(Instant.now()); - //validationService.validateForce(persist); + //validationService.validateForce(persist); //TODO if (isNotificationConsistent(persist)) { notificationService.persist(persist, null); auditService.track(AuditableAction.Notification_Persist, "notification_event", event); diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java index 47d3343fc..5c3082a45 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java @@ -230,14 +230,14 @@ public class DescriptionServiceImpl implements DescriptionService { } } - private NotificationIntegrationEvent applyNotificationType(DescriptionStatus status, NotificationIntegrationEvent event) throws InvalidApplicationException { + private NotificationIntegrationEvent applyNotificationType(DescriptionStatus status, NotificationIntegrationEvent event) { switch (status) { case Draft: event.setNotificationType(UUID.fromString(notificationProperties.getDescriptionModified())); case Finalized: event.setNotificationType(UUID.fromString(notificationProperties.getDescriptionFinalised())); default: - throw new InvalidApplicationException("Unsupported Description Status."); + throw new MyApplicationException("Unsupported Description Status."); } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java index 64842335e..5a927b055 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java @@ -198,7 +198,7 @@ public class DmpServiceImpl implements DmpService { } } - private NotificationIntegrationEvent applyNotificationType(DmpStatus status, NotificationIntegrationEvent event) throws InvalidApplicationException { + private NotificationIntegrationEvent applyNotificationType(DmpStatus status, NotificationIntegrationEvent event) { switch (status) { case Draft: event.setNotificationType(UUID.fromString(notificationProperties.getDmpModified())); @@ -207,7 +207,7 @@ public class DmpServiceImpl implements DmpService { event.setNotificationType(UUID.fromString(notificationProperties.getDmpFinalised())); return event; default: - throw new InvalidApplicationException("Unsupported Dmp Status."); + throw new MyApplicationException("Unsupported Dmp Status."); } } @@ -744,13 +744,13 @@ public class DmpServiceImpl implements DmpService { ActionConfirmationEntity action = this.queryFactory.query(ActionConfirmationQuery.class).tokens(token).types(ActionConfirmationType.DmpInvitation).isActive(IsActive.Active).first(); if (action == null){ - throw new InvalidApplicationException("Token does not exist!"); + throw new MyApplicationException("Token does not exist!"); } if (action.getStatus().equals(ActionConfirmationStatus.Accepted)){ - throw new InvalidApplicationException("Invitation is already confirmed!"); + throw new MyApplicationException("Invitation is already confirmed!"); } if (action.getExpiresAt().compareTo(Instant.now()) < 0){ - throw new InvalidApplicationException("Token has expired!"); + throw new MyApplicationException("Token has expired!"); } DmpInvitationEntity dmpInvitation = this.xmlHandlingService.fromXmlSafe(DmpInvitationEntity.class, action.getData()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/UserController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/UserController.java index 0b90776d0..b1fd01579 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/UserController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/UserController.java @@ -255,9 +255,9 @@ public class UserController { this.userTypeService.sendMergeAccountConfirmation(email); -// this.auditService.track(AuditableAction.Dmp_Invite_Users, Map.ofEntries( -// new AbstractMap.SimpleEntry("model", model) -// )); + this.auditService.track(AuditableAction.User_MergeRequest, Map.ofEntries( + new AbstractMap.SimpleEntry("email", email) + )); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).payload("Merge Account Request Success")); } @@ -269,9 +269,9 @@ public class UserController { this.userTypeService.confirmMergeAccount(token); -// this.auditService.track(AuditableAction.Dmp_Invite_Users, Map.ofEntries( -// new AbstractMap.SimpleEntry("model", model) -// )); + this.auditService.track(AuditableAction.User_MergeConfirm, Map.ofEntries( + new AbstractMap.SimpleEntry("token", token) + )); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).payload("Merge Account Confirm Success")); } @@ -283,9 +283,9 @@ public class UserController { this.userTypeService.sendRemoveCredentialConfirmation(email); -// this.auditService.track(AuditableAction.Dmp_Invite_Users, Map.ofEntries( -// new AbstractMap.SimpleEntry("model", model) -// )); + this.auditService.track(AuditableAction.User_RemoveCredentialRequest, Map.ofEntries( + new AbstractMap.SimpleEntry("email", email) + )); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).payload("Remove Credential Request Success")); } @@ -297,9 +297,9 @@ public class UserController { this.userTypeService.confirmRemoveCredential(token); -// this.auditService.track(AuditableAction.Dmp_Invite_Users, Map.ofEntries( -// new AbstractMap.SimpleEntry("model", model) -// )); + this.auditService.track(AuditableAction.User_RemoveCredentialConfirm, Map.ofEntries( + new AbstractMap.SimpleEntry("model", token) + )); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).payload("Remove Credential Account Success")); }