Fixes on notification service and core

This commit is contained in:
Thomas Georgios Giannos 2024-01-19 15:12:33 +02:00
parent d4739ed1d0
commit a56a9075b1
23 changed files with 323 additions and 130 deletions

View File

@ -2,9 +2,11 @@ package eu.eudat.data;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.converters.enums.IsActiveConverter;
import eu.eudat.data.types.JsonSQLType;
import gr.cite.queueinbox.entity.QueueInbox;
import gr.cite.queueinbox.entity.QueueInboxStatus;
import jakarta.persistence.*;
import org.hibernate.annotations.Type;
import java.time.Instant;
import java.util.UUID;
@ -37,6 +39,7 @@ public class QueueInboxEntity implements QueueInbox {
private UUID messageId;
public final static String _messageId = "messageId";
@Type(JsonSQLType.class)
@Column(name = "\"message\"", columnDefinition = "json", nullable = false)
private String message;
public final static String _message = "message";

View File

@ -0,0 +1,80 @@
package eu.eudat.data.types;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.SqlTypes;
import org.hibernate.usertype.UserType;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
public class JsonSQLType implements UserType<String> {
@Override
public int getSqlType() {
return SqlTypes.JSON;
}
@Override
public Class<String> returnedClass() {
return String.class;
}
@Override
public boolean equals(String x, String y) {
if (x == null) {
return y == null;
} else {
return x.equals(y);
}
}
@Override
public int hashCode(String x) {
return x.hashCode();
}
@Override
public String nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException {
String json = rs.getString(position);
return rs.wasNull() ? null : json;
}
@Override
public void nullSafeSet(PreparedStatement st, String value, int index, SharedSessionContractImplementor session) throws SQLException {
if (value == null) {
st.setNull(index, Types.OTHER);
} else {
st.setObject(index, value, Types.OTHER);
}
}
@Override
public String deepCopy(String value) throws HibernateException {
return value;
}
@Override
public boolean isMutable() {
return false;
}
@Override
public Serializable disassemble(String value) throws HibernateException {
return value;
}
@Override
public String assemble(Serializable cached, Object owner) throws HibernateException {
return (String) cached;
}
@Override
public String replace(String original, String target, Object owner) throws HibernateException {
return original;
}
}

View File

@ -1,7 +0,0 @@
package eu.eudat.integrationevent.outbox.notification;
import javax.management.InvalidApplicationException;
public interface NotificationIntegrationEventHandler {
void handle(NotificationIntegrationEvent event) throws InvalidApplicationException;
}

View File

@ -5,16 +5,25 @@ import eu.eudat.integrationevent.TrackedEvent;
import java.util.UUID;
public class NotificationIntegrationEvent extends TrackedEvent {
public class NotifyIntegrationEvent extends TrackedEvent {
private UUID userId;
private UUID tenant;
private UUID tenantId;
private UUID notificationType;
private NotificationContactType contactTypeHint;
private String contactHint;
private String data;
private String provenanceRef;
public NotifyIntegrationEvent() {
}
public UUID getUserId() {
return userId;
}
@ -23,12 +32,12 @@ public class NotificationIntegrationEvent extends TrackedEvent {
this.userId = userId;
}
public UUID getTenant() {
return tenant;
public UUID getTenantId() {
return tenantId;
}
public void setTenant(UUID tenant) {
this.tenant = tenant;
public void setTenantId(UUID tenantId) {
this.tenantId = tenantId;
}
public UUID getNotificationType() {

View File

@ -0,0 +1,7 @@
package eu.eudat.integrationevent.outbox.notification;
import javax.management.InvalidApplicationException;
public interface NotifyIntegrationEventHandler {
void handle(NotifyIntegrationEvent event) throws InvalidApplicationException;
}

View File

@ -1,10 +1,6 @@
package eu.eudat.integrationevent.outbox.notification;
import eu.eudat.audit.AuditableAction;
import eu.eudat.commons.enums.ContactInfoType;
import eu.eudat.commons.enums.notification.NotificationNotifyState;
import eu.eudat.commons.enums.notification.NotificationTrackingProcess;
import eu.eudat.commons.enums.notification.NotificationTrackingState;
import eu.eudat.data.UserContactInfoEntity;
import eu.eudat.data.UserEntity;
import eu.eudat.integrationevent.outbox.OutboxIntegrationEvent;
@ -24,15 +20,14 @@ import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
import javax.management.InvalidApplicationException;
import java.time.Instant;
import java.util.List;
import java.util.UUID;
@Component
@RequestScope
public class NotificationIntegrationEventHandlerImpl implements NotificationIntegrationEventHandler {
public class NotifyIntegrationEventHandlerImpl implements NotifyIntegrationEventHandler {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(NotificationIntegrationEventHandlerImpl.class));
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(NotifyIntegrationEventHandlerImpl.class));
private final NotificationService notificationService;
@ -45,7 +40,7 @@ public class NotificationIntegrationEventHandlerImpl implements NotificationInte
private final ValidatorFactory validatorFactory;
@Autowired
public NotificationIntegrationEventHandlerImpl(
public NotifyIntegrationEventHandlerImpl(
OutboxService outboxService,
NotificationService notificationService,
QueryFactory queryFactory,
@ -58,31 +53,12 @@ public class NotificationIntegrationEventHandlerImpl implements NotificationInte
}
@Override
public void handle(NotificationIntegrationEvent event) throws InvalidApplicationException {
public void handle(NotifyIntegrationEvent event) throws InvalidApplicationException {
OutboxIntegrationEvent message = new OutboxIntegrationEvent();
message.setMessageId(UUID.randomUUID());
message.setType(OutboxIntegrationEvent.NOTIFY);
message.setEvent(event);
this.outboxService.publish(message);
// NotificationPersist persist = new NotificationPersist();
// persist.setType(event.getNotificationType());
// persist.setUserId(event.getUserId());
// persist.setContactHint(event.getContactHint());
// persist.setContactTypeHint(event.getContactTypeHint());
// persist.setData(event.getData());
// persist.setNotifyState(NotificationNotifyState.PENDING);
// persist.setNotifiedWith(event.getContactTypeHint());
// persist.setRetryCount(0);
// persist.setTrackingState(NotificationTrackingState.UNDEFINED);
// persist.setTrackingProcess(NotificationTrackingProcess.PENDING);
// persist.setTrackingData(null);
// persist.setProvenanceRef(event.getProvenanceRef());
// persist.setNotifiedAt(Instant.now());
// validatorFactory.validator(NotificationPersist.NotificationPersistValidator.class).validateForce(persist);
// if (isNotificationConsistent(persist)) {
// notificationService.persist(persist, null);
// auditService.track(AuditableAction.Notification_Persist, "notification_event", event);
// }
}
private boolean isNotificationConsistent(NotificationPersist notification) {

View File

@ -8,8 +8,8 @@ import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.commons.types.notification.*;
import eu.eudat.configurations.notification.NotificationProperties;
import eu.eudat.data.UserContactInfoEntity;
import eu.eudat.integrationevent.outbox.notification.NotificationIntegrationEvent;
import eu.eudat.integrationevent.outbox.notification.NotificationIntegrationEventHandler;
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEvent;
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEventHandler;
import eu.eudat.model.UserContactInfo;
import eu.eudat.model.persist.ContactSupportPersist;
import eu.eudat.model.persist.PublicContactSupportPersist;
@ -41,7 +41,7 @@ public class ContactSupportServiceImpl implements ContactSupportService {
private final UserScope userScope;
private final NotificationIntegrationEventHandler notificationIntegrationEventHandler;
private final NotifyIntegrationEventHandler notifyIntegrationEventHandler;
private final NotificationProperties notificationProperties;
@Autowired
@ -50,13 +50,13 @@ public class ContactSupportServiceImpl implements ContactSupportService {
QueryFactory queryFactory,
JsonHandlingService jsonHandlingService,
UserScope userScope,
NotificationIntegrationEventHandler notificationIntegrationEventHandler,
NotifyIntegrationEventHandler notifyIntegrationEventHandler,
NotificationProperties notificationProperties) {
this.authorizationService = authorizationService;
this.queryFactory = queryFactory;
this.jsonHandlingService = jsonHandlingService;
this.userScope = userScope;
this.notificationIntegrationEventHandler = notificationIntegrationEventHandler;
this.notifyIntegrationEventHandler = notifyIntegrationEventHandler;
this.notificationProperties = notificationProperties;
}
@ -65,7 +65,7 @@ public class ContactSupportServiceImpl implements ContactSupportService {
logger.debug(new MapLogEntry("send contact email").And("model", model));
this.authorizationService.authorizeForce(Permission.SendContactSupport);
NotificationIntegrationEvent event = new NotificationIntegrationEvent();
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(this.userScope.getUserId());
query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal));
@ -86,7 +86,7 @@ public class ContactSupportServiceImpl implements ContactSupportService {
data.setFields(fieldInfoList);
event.setData(jsonHandlingService.toJsonSafe(data));
notificationIntegrationEventHandler.handle(event);
notifyIntegrationEventHandler.handle(event);
}
@Override
@ -94,7 +94,7 @@ public class ContactSupportServiceImpl implements ContactSupportService {
logger.debug(new MapLogEntry("public send contact email").And("model", model));
this.authorizationService.authorizeForce(Permission.PublicSendContactSupport);
NotificationIntegrationEvent event = new NotificationIntegrationEvent();
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
List<ContactPair> contactPairs = new ArrayList<>();
contactPairs.add(new ContactPair(ContactInfoType.Email, notificationProperties.getContactSupportEmail()));
@ -112,7 +112,7 @@ public class ContactSupportServiceImpl implements ContactSupportService {
data.setFields(fieldInfoList);
event.setData(jsonHandlingService.toJsonSafe(data));
notificationIntegrationEventHandler.handle(event);
notifyIntegrationEventHandler.handle(event);
}

View File

@ -1,6 +1,5 @@
package eu.eudat.service.description;
import com.fasterxml.jackson.core.JsonProcessingException;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.JsonHandlingService;
@ -21,8 +20,8 @@ import eu.eudat.data.*;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.event.DescriptionTouchedEvent;
import eu.eudat.event.EventBroker;
import eu.eudat.integrationevent.outbox.notification.NotificationIntegrationEvent;
import eu.eudat.integrationevent.outbox.notification.NotificationIntegrationEventHandler;
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEvent;
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEventHandler;
import eu.eudat.model.*;
import eu.eudat.model.builder.DescriptionBuilder;
import eu.eudat.model.deleter.DescriptionDeleter;
@ -100,7 +99,7 @@ public class DescriptionServiceImpl implements DescriptionService {
private final XmlHandlingService xmlHandlingService;
private final FileTransformerService fileTransformerService;
private final NotificationIntegrationEventHandler eventHandler;
private final NotifyIntegrationEventHandler eventHandler;
private final NotificationProperties notificationProperties;
@ -120,7 +119,7 @@ public class DescriptionServiceImpl implements DescriptionService {
QueryFactory queryFactory,
JsonHandlingService jsonHandlingService,
UserScope userScope,
XmlHandlingService xmlHandlingService, NotificationIntegrationEventHandler eventHandler, NotificationProperties notificationProperties, FileTransformerService fileTransformerService, ElasticService elasticService) {
XmlHandlingService xmlHandlingService, NotifyIntegrationEventHandler eventHandler, NotificationProperties notificationProperties, FileTransformerService fileTransformerService, ElasticService elasticService) {
this.entityManager = entityManager;
this.authorizationService = authorizationService;
this.deleterFactory = deleterFactory;
@ -225,7 +224,7 @@ public class DescriptionServiceImpl implements DescriptionService {
}
private void createDescriptionNotificationEvent(DescriptionEntity description, UserEntity user, NotificationContactType type) throws InvalidApplicationException {
NotificationIntegrationEvent event = new NotificationIntegrationEvent();
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
event.setUserId(this.userScope.getUserId());
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId());
@ -250,7 +249,7 @@ public class DescriptionServiceImpl implements DescriptionService {
eventHandler.handle(event);
}
private NotificationIntegrationEvent applyNotificationType(DescriptionStatus status, NotificationIntegrationEvent event) {
private NotifyIntegrationEvent applyNotificationType(DescriptionStatus status, NotifyIntegrationEvent event) {
switch (status) {
case Draft:
event.setNotificationType(notificationProperties.getDescriptionModifiedType());

View File

@ -19,8 +19,8 @@ import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.UserDescriptionTemplateEntity;
import eu.eudat.data.UserEntity;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.integrationevent.outbox.notification.NotificationIntegrationEvent;
import eu.eudat.integrationevent.outbox.notification.NotificationIntegrationEventHandler;
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEvent;
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEventHandler;
import eu.eudat.model.DescriptionTemplate;
import eu.eudat.model.UserContactInfo;
import eu.eudat.model.builder.DescriptionTemplateBuilder;
@ -116,7 +116,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
private final JsonHandlingService jsonHandlingService;
private final NotificationIntegrationEventHandler eventHandler;
private final NotifyIntegrationEventHandler eventHandler;
private final NotificationProperties notificationProperties;
@ -137,7 +137,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
ResponseUtilsService responseUtilsService,
StorageFileService storageFileService,
JsonHandlingService jsonHandlingService,
NotificationIntegrationEventHandler eventHandler,
NotifyIntegrationEventHandler eventHandler,
NotificationProperties notificationProperties,
ValidatorFactory validatorFactory) {
this.entityManager = entityManager;
@ -237,8 +237,8 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
}
private void sendDescriptionTemplateInvitationEvent(UserDescriptionTemplateEntity userDescriptionTemplate, NotificationContactType type) throws InvalidApplicationException {
NotificationIntegrationEvent event = new NotificationIntegrationEvent();
event.setTenant(tenantScope.getTenant());
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
event.setTenantId(tenantScope.getTenant());
event.setUserId(userScope.getUserIdSafe());
UserEntity user = this.entityManager.find(UserEntity.class, userDescriptionTemplate.getUserId());

View File

@ -22,8 +22,8 @@ import eu.eudat.data.*;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.event.DmpTouchedEvent;
import eu.eudat.event.EventBroker;
import eu.eudat.integrationevent.outbox.notification.NotificationIntegrationEvent;
import eu.eudat.integrationevent.outbox.notification.NotificationIntegrationEventHandler;
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEvent;
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEventHandler;
import eu.eudat.model.Dmp;
import eu.eudat.model.DmpUser;
import eu.eudat.model.Reference;
@ -112,13 +112,13 @@ public class DmpServiceImpl implements DmpService {
private final DescriptionService descriptionService;
private final FileTransformerService fileTransformerService;
private final NotificationIntegrationEventHandler eventHandler;
private final NotifyIntegrationEventHandler eventHandler;
private final NotificationProperties notificationProperties;
private final ActionConfirmationService actionConfirmationService;
private final ValidatorFactory validatorFactory;
private final gr.cite.tools.validation.ValidatorFactory validatorFactory;
private final ElasticService elasticService;
@ -134,7 +134,15 @@ public class DmpServiceImpl implements DmpService {
MessageSource messageSource,
XmlHandlingService xmlHandlingService,
JsonHandlingService jsonHandlingService,
UserScope userScope, EventBroker eventBroker, DescriptionService descriptionService, NotificationIntegrationEventHandler eventHandler, NotificationProperties notificationProperties, ActionConfirmationService actionConfirmationService, FileTransformerService fileTransformerService, ValidatorFactory validatorFactory, ElasticService elasticService) {
UserScope userScope,
EventBroker eventBroker,
DescriptionService descriptionService,
NotifyIntegrationEventHandler eventHandler,
NotificationProperties notificationProperties,
ActionConfirmationService actionConfirmationService,
FileTransformerService fileTransformerService,
ValidatorFactory validatorFactory,
ElasticService elasticService) {
this.entityManager = entityManager;
this.authorizationService = authorizationService;
this.deleterFactory = deleterFactory;
@ -196,7 +204,7 @@ public class DmpServiceImpl implements DmpService {
}
private void createDmpNotificationEvent(DmpEntity dmp, UserEntity user, NotificationContactType type) throws InvalidApplicationException {
NotificationIntegrationEvent event = new NotificationIntegrationEvent();
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
event.setUserId(this.userScope.getUserId());
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId());
query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal));
@ -220,7 +228,7 @@ public class DmpServiceImpl implements DmpService {
eventHandler.handle(event);
}
private NotificationIntegrationEvent applyNotificationType(DmpStatus status, NotificationIntegrationEvent event) {
private NotifyIntegrationEvent applyNotificationType(DmpStatus status, NotifyIntegrationEvent event) {
switch (status) {
case Draft:
event.setNotificationType(notificationProperties.getDmpModifiedType());
@ -785,7 +793,7 @@ public class DmpServiceImpl implements DmpService {
private void createDmpInvitationExistingUserEvent(UserEntity recipient, DmpEntity dmp, DmpUserRole role, String email, NotificationContactType type) throws InvalidApplicationException {
NotificationIntegrationEvent event = new NotificationIntegrationEvent();
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
event.setUserId(this.userScope.getUserIdSafe());
List<ContactPair> contactPairs = new ArrayList<>();
@ -809,7 +817,7 @@ public class DmpServiceImpl implements DmpService {
private void sendDmpInvitationExternalUser(String email, DmpEntity dmp, DmpUserRole role) throws JAXBException, InvalidApplicationException {
String token = this.createActionConfirmation(email, dmp, role);
NotificationIntegrationEvent event = new NotificationIntegrationEvent();
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
event.setUserId(this.userScope.getUserIdSafe());
List<ContactPair> contactPairs = new ArrayList<>();

View File

@ -23,8 +23,8 @@ import eu.eudat.data.*;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.event.UserTouchedEvent;
import eu.eudat.event.EventBroker;
import eu.eudat.integrationevent.outbox.notification.NotificationIntegrationEvent;
import eu.eudat.integrationevent.outbox.notification.NotificationIntegrationEventHandler;
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEvent;
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEventHandler;
import eu.eudat.model.User;
import eu.eudat.model.UserContactInfo;
import eu.eudat.model.UserCredential;
@ -99,7 +99,7 @@ public class UserServiceImpl implements UserService {
private final KeycloakService keycloakService;
private final ActionConfirmationService actionConfirmationService;
private final NotificationProperties notificationProperties;
private final NotificationIntegrationEventHandler eventHandler;
private final NotifyIntegrationEventHandler eventHandler;
private final ValidatorFactory validatorFactory;
@ -117,7 +117,7 @@ public class UserServiceImpl implements UserService {
EventBroker eventBroker,
JsonHandlingService jsonHandlingService,
XmlHandlingService xmlHandlingService, QueryFactory queryFactory,
UserScope userScope, KeycloakService keycloakService, ActionConfirmationService actionConfirmationService, NotificationProperties notificationProperties, NotificationIntegrationEventHandler eventHandler, ValidatorFactory validatorFactory, ElasticService elasticService) {
UserScope userScope, KeycloakService keycloakService, ActionConfirmationService actionConfirmationService, NotificationProperties notificationProperties, NotifyIntegrationEventHandler eventHandler, ValidatorFactory validatorFactory, ElasticService elasticService) {
this.entityManager = entityManager;
this.authorizationService = authorizationService;
this.deleterFactory = deleterFactory;
@ -363,7 +363,7 @@ public class UserServiceImpl implements UserService {
}
private void createMergeNotificationEvent(String token, UserEntity user, String email, NotificationContactType type) throws InvalidApplicationException {
NotificationIntegrationEvent event = new NotificationIntegrationEvent();
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
event.setUserId(user.getId());
List<ContactPair> contactPairs = new ArrayList<>();
contactPairs.add(new ContactPair(ContactInfoType.Email, email));
@ -393,7 +393,7 @@ public class UserServiceImpl implements UserService {
}
private void createRemoveCredentialNotificationEvent(String token, UUID userId, NotificationContactType type) throws InvalidApplicationException {
NotificationIntegrationEvent event = new NotificationIntegrationEvent();
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
event.setUserId(userId);
event.setContactTypeHint(type);
event.setNotificationType(notificationProperties.getRemoveCredentialConfirmationType());

View File

@ -1,3 +0,0 @@
artifactId=core
groupId=eu.eudat
version=1.0.0-SNAPSHOT

View File

@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

View File

@ -9,7 +9,7 @@ spring:
queue:
rabbitmq:
enable: false
app-id: ${THE_API_ID}
app-id: ${QUEUE_APP_ID}
durable: null
queue: null
exchange: null

View File

@ -9,7 +9,7 @@ spring:
queue:
rabbitmq:
enable: false
app-id: ${THE_API_ID}
app-id: ${QUEUE_APP_ID}
durable: null
queue: null
exchange: null

View File

@ -2,10 +2,14 @@ package gr.cite.notification.data;
import gr.cite.notification.common.enums.IsActive;
import gr.cite.notification.data.conventers.IsActiveConverter;
import gr.cite.notification.data.types.JsonSQLType;
import gr.cite.queueinbox.entity.QueueInbox;
import gr.cite.queueinbox.entity.QueueInboxStatus;
import jakarta.persistence.*;
import org.hibernate.annotations.Type;
import org.hibernate.usertype.UserType;
import java.time.Instant;
import java.util.UUID;
@ -37,6 +41,7 @@ public class QueueInboxEntity implements QueueInbox {
private UUID messageId;
public final static String _messageId = "messageId";
@Type(JsonSQLType.class)
@Column(name = "\"message\"", columnDefinition = "json", nullable = false)
private String message;
public final static String _message = "message";

View File

@ -0,0 +1,80 @@
package gr.cite.notification.data.types;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.SqlTypes;
import org.hibernate.usertype.UserType;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
public class JsonSQLType implements UserType<String> {
@Override
public int getSqlType() {
return SqlTypes.JSON;
}
@Override
public Class<String> returnedClass() {
return String.class;
}
@Override
public boolean equals(String x, String y) {
if (x == null) {
return y == null;
} else {
return x.equals(y);
}
}
@Override
public int hashCode(String x) {
return x.hashCode();
}
@Override
public String nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException {
String json = rs.getString(position);
return rs.wasNull() ? null : json;
}
@Override
public void nullSafeSet(PreparedStatement st, String value, int index, SharedSessionContractImplementor session) throws SQLException {
if (value == null) {
st.setNull(index, Types.OTHER);
} else {
st.setObject(index, value, Types.OTHER);
}
}
@Override
public String deepCopy(String value) throws HibernateException {
return value;
}
@Override
public boolean isMutable() {
return false;
}
@Override
public Serializable disassemble(String value) throws HibernateException {
return value;
}
@Override
public String assemble(Serializable cached, Object owner) throws HibernateException {
return (String) cached;
}
@Override
public String replace(String original, String target, Object owner) throws HibernateException {
return original;
}
}

View File

@ -48,4 +48,5 @@ public class AppRabbitConfigurer extends RabbitConfigurer {
return inboxRepository.create(params) != null;
};
}
}

View File

@ -4,20 +4,19 @@ import gr.cite.notification.integrationevent.inbox.InboxProperties;
import gr.cite.notification.integrationevent.inbox.InboxRepositoryImpl;
import gr.cite.queueinbox.InboxConfigurer;
import gr.cite.queueinbox.repository.InboxRepository;
import jakarta.persistence.EntityManagerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;
@Configuration
@EnableConfigurationProperties({InboxProperties.class})
@ConditionalOnProperty(prefix = "queue.task.listener", name = "enable", matchIfMissing = false)
public class InboxIntegrationEventConfigurer extends InboxConfigurer {
private ApplicationContext applicationContext;
private InboxProperties inboxProperties;
public InboxIntegrationEventConfigurer(ApplicationContext applicationContext, InboxProperties inboxProperties) {

View File

@ -21,6 +21,9 @@ public class NotifyIntegrationEvent extends TrackedEvent {
private String provenanceRef;
public NotifyIntegrationEvent() {
}
public UUID getUserId() {
return userId;
}

View File

@ -150,7 +150,7 @@ public class NotifyIntegrationEventHandlerImpl implements NotifyIntegrationEvent
} catch (Exception ex) {
logger.error("Problem getting list of queue outbox. Skipping: {}", ex.getMessage(), ex);
}
return null;
return EventProcessingStatus.Success;
}
}

View File

@ -130,7 +130,7 @@
<dependency>
<groupId>gr.cite</groupId>
<artifactId>rabbitmq-core</artifactId>
<version>1.0.0</version>
<version>2.1.1</version>
</dependency>
<dependency>

View File

@ -9,7 +9,7 @@ spring:
queue:
rabbitmq:
enable: false
app-id: ${THE_API_ID}
app-id: ${QUEUE_APP_ID}
durable: null
queue: null
exchange: null