change exception for confirm notifications requests

This commit is contained in:
amentis 2023-12-15 10:15:00 +02:00
parent 3990be182c
commit bcd42e7ec1
5 changed files with 24 additions and 20 deletions

View File

@ -81,6 +81,10 @@ public class AuditableAction {
public static final EventId User_LanguageMine = new EventId(11007, "User_LanguageMine"); 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_TimezoneMine = new EventId(11008, "User_TimezoneMine");
public static final EventId User_CultureMine = new EventId(11009, "User_CultureMine"); 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_Query = new EventId(12000, "Tenant_Query");
public static final EventId Tenant_Lookup = new EventId(12001, "Tenant_Lookup"); public static final EventId Tenant_Lookup = new EventId(12001, "Tenant_Lookup");

View File

@ -75,7 +75,7 @@ public class NotificationIntegrationEventHandlerImpl implements NotificationInte
persist.setTrackingData(null); persist.setTrackingData(null);
persist.setProvenanceRef(event.getProvenanceRef()); persist.setProvenanceRef(event.getProvenanceRef());
persist.setNotifiedAt(Instant.now()); persist.setNotifiedAt(Instant.now());
//validationService.validateForce(persist); //validationService.validateForce(persist); //TODO
if (isNotificationConsistent(persist)) { if (isNotificationConsistent(persist)) {
notificationService.persist(persist, null); notificationService.persist(persist, null);
auditService.track(AuditableAction.Notification_Persist, "notification_event", event); auditService.track(AuditableAction.Notification_Persist, "notification_event", event);

View File

@ -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) { switch (status) {
case Draft: case Draft:
event.setNotificationType(UUID.fromString(notificationProperties.getDescriptionModified())); event.setNotificationType(UUID.fromString(notificationProperties.getDescriptionModified()));
case Finalized: case Finalized:
event.setNotificationType(UUID.fromString(notificationProperties.getDescriptionFinalised())); event.setNotificationType(UUID.fromString(notificationProperties.getDescriptionFinalised()));
default: default:
throw new InvalidApplicationException("Unsupported Description Status."); throw new MyApplicationException("Unsupported Description Status.");
} }
} }

View File

@ -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) { switch (status) {
case Draft: case Draft:
event.setNotificationType(UUID.fromString(notificationProperties.getDmpModified())); event.setNotificationType(UUID.fromString(notificationProperties.getDmpModified()));
@ -207,7 +207,7 @@ public class DmpServiceImpl implements DmpService {
event.setNotificationType(UUID.fromString(notificationProperties.getDmpFinalised())); event.setNotificationType(UUID.fromString(notificationProperties.getDmpFinalised()));
return event; return event;
default: 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(); ActionConfirmationEntity action = this.queryFactory.query(ActionConfirmationQuery.class).tokens(token).types(ActionConfirmationType.DmpInvitation).isActive(IsActive.Active).first();
if (action == null){ if (action == null){
throw new InvalidApplicationException("Token does not exist!"); throw new MyApplicationException("Token does not exist!");
} }
if (action.getStatus().equals(ActionConfirmationStatus.Accepted)){ 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){ 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()); DmpInvitationEntity dmpInvitation = this.xmlHandlingService.fromXmlSafe(DmpInvitationEntity.class, action.getData());

View File

@ -255,9 +255,9 @@ public class UserController {
this.userTypeService.sendMergeAccountConfirmation(email); this.userTypeService.sendMergeAccountConfirmation(email);
// this.auditService.track(AuditableAction.Dmp_Invite_Users, Map.ofEntries( this.auditService.track(AuditableAction.User_MergeRequest, Map.ofEntries(
// new AbstractMap.SimpleEntry<String, Object>("model", model) new AbstractMap.SimpleEntry<String, Object>("email", email)
// )); ));
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).payload("Merge Account Request Success")); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).payload("Merge Account Request Success"));
} }
@ -269,9 +269,9 @@ public class UserController {
this.userTypeService.confirmMergeAccount(token); this.userTypeService.confirmMergeAccount(token);
// this.auditService.track(AuditableAction.Dmp_Invite_Users, Map.ofEntries( this.auditService.track(AuditableAction.User_MergeConfirm, Map.ofEntries(
// new AbstractMap.SimpleEntry<String, Object>("model", model) new AbstractMap.SimpleEntry<String, Object>("token", token)
// )); ));
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).payload("Merge Account Confirm Success")); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).payload("Merge Account Confirm Success"));
} }
@ -283,9 +283,9 @@ public class UserController {
this.userTypeService.sendRemoveCredentialConfirmation(email); this.userTypeService.sendRemoveCredentialConfirmation(email);
// this.auditService.track(AuditableAction.Dmp_Invite_Users, Map.ofEntries( this.auditService.track(AuditableAction.User_RemoveCredentialRequest, Map.ofEntries(
// new AbstractMap.SimpleEntry<String, Object>("model", model) new AbstractMap.SimpleEntry<String, Object>("email", email)
// )); ));
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).payload("Remove Credential Request Success")); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).payload("Remove Credential Request Success"));
} }
@ -297,9 +297,9 @@ public class UserController {
this.userTypeService.confirmRemoveCredential(token); this.userTypeService.confirmRemoveCredential(token);
// this.auditService.track(AuditableAction.Dmp_Invite_Users, Map.ofEntries( this.auditService.track(AuditableAction.User_RemoveCredentialConfirm, Map.ofEntries(
// new AbstractMap.SimpleEntry<String, Object>("model", model) new AbstractMap.SimpleEntry<String, Object>("model", token)
// )); ));
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).payload("Remove Credential Account Success")); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).payload("Remove Credential Account Success"));
} }