Fixes on notification service NotifyIntegrationEventHandler

This commit is contained in:
Thomas Georgios Giannos 2024-01-22 18:03:34 +02:00
parent 101a0aace9
commit 21b5201bf2
3 changed files with 16 additions and 4 deletions

View File

@ -4,4 +4,7 @@ validation.lowerthanmin=Value must be larger than {value}
validation.largerthanmax=Value must be less than {value}
validation.invalidid=Not valid id
General_ItemNotFound=Item {0} of type {1} not found
Validation_Required={0} is required
Validation_Required={0} is required
Validation_OverPosting=Too much info
Validation_MaxLength={0} too long
Validation_UnexpectedValue=Unexpected value in field {0}

View File

@ -67,6 +67,7 @@ public class NotifyIntegrationEventHandlerImpl implements NotifyIntegrationEvent
if (event.getUserId() == null) {
throw new MyValidationException(this.errors.getModelValidation().getCode(), "userId", messageSource.getMessage("Validation_Required", new Object[]{"userId"}, LocaleContextHolder.getLocale()));
}
logger.debug("Handling NotifyIntegrationEvent");
NotificationPersist model = new NotificationPersist();
model.setType(event.getNotificationType());
@ -132,8 +133,6 @@ public class NotifyIntegrationEventHandlerImpl implements NotifyIntegrationEvent
} finally {
currentPrincipalResolver.pop();
}
transaction.commit();
} catch (OptimisticLockException ex) {
// we get this if/when someone else already modified the notifications. We want to essentially ignore this, and keep working
logger.debug("Concurrency exception getting queue outbox. Skipping: {} ", ex.getMessage());

View File

@ -34,6 +34,7 @@ import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import jakarta.transaction.Transactional;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@ -96,10 +97,11 @@ public class NotificationServiceImpl implements NotificationService {
}
@Override
@Transactional
public Notification persist(NotificationPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException {
logger.debug(new MapLogEntry("persisting notification").And("model", model).And("fields", fields));
this.authorizationService.authorizeForce(Permission.EditNotification);
// this.authorizationService.authorizeForce(Permission.EditNotification);
Boolean isUpdate = this.conventionService.isValidGuid(model.getId());
@ -120,6 +122,14 @@ public class NotificationServiceImpl implements NotificationService {
data.setContactTypeHint(model.getContactTypeHint());
data.setType(model.getType());
data.setUserId(model.getUserId());
data.setNotifyState(model.getNotifyState());
data.setTrackingProcess(model.getTrackingProcess());
data.setNotifiedWith(model.getNotifiedWith());
data.setTrackingData(model.getTrackingData());
data.setTrackingState(model.getTrackingState());
data.setNotifiedAt(model.getNotifiedAt());
data.setRetryCount(model.getRetryCount());
data.setData(model.getData());
data.setUpdatedAt(Instant.now());
if (isUpdate) this.entityManager.merge(data);