use of eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogServiceBean method resend.
@Override
public void resend(List<String> messageIdList, String username) throws ExchangeLogException {
log.debug("resend in service layer:{} {}", messageIdList, username);
List<UnsentMessageType> unsentMessageList;
try {
unsentMessageList = unsentModel.resend(messageIdList);
sendAuditLogMessageForResendUnsentMessage(messageIdList.toString(), username);
} catch (ExchangeModelException e) {
log.error("Couldn't read unsent messages", e);
throw new ExchangeLogException("Couldn't read unsent messages");
}
if (unsentMessageList != null && !unsentMessageList.isEmpty()) {
sendingQueueEvent.fire(new NotificationMessage("messageIds", messageIdList));
for (UnsentMessageType unsentMessage : unsentMessageList) {
try {
String unsentMessageId = producer.sendMessageOnQueue(unsentMessage.getMessage(), MessageQueue.EVENT);
// TextMessage unsentResponse = consumer.getMessage(unsentMessageId, TextMessage.class);
sendAuditLogMessageForCreateUnsentMessage(unsentMessageId, username);
// ExchangeModuleResponseMapper.validateResponse(unsentResponse, unsentMessageId);
} catch (ExchangeMessageException e) {
log.error("Error when sending/receiving message {} {}", messageIdList, e);
}
}
}
}
use of eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageType in project UVMS-ExchangeModule-APP by UnionVMS.
the class UnsentModelBean method resend.
@Override
public List<UnsentMessageType> resend(List<String> unsentMessageId) throws ExchangeModelException {
if (unsentMessageId == null) {
throw new InputArgumentException("No messageList to resend");
}
try {
List<UnsentMessageType> unsentMessageList = new ArrayList<>();
for (String messageId : unsentMessageId) {
try {
UnsentMessage message = dao.getByGuid(messageId);
UnsentMessage removedMessage = dao.remove(message);
unsentMessageList.add(UnsentMessageMapper.toModel(removedMessage));
} catch (NoEntityFoundException e) {
LOG.error("Couldn't find message to resend with guid: " + messageId);
}
}
return unsentMessageList;
} catch (ExchangeDaoException ex) {
LOG.error("[ Error when resending message message list ] {}", ex.getMessage());
throw new ExchangeModelException("Error when resending unsent message list");
}
}
use of eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogServiceBean method createUnsentMessage.
@Override
public String createUnsentMessage(String senderReceiver, Date timestamp, String recipient, String message, List<UnsentMessageTypeProperty> properties, String username) throws ExchangeLogException {
log.debug("createUnsentMessage in service layer:{}", message);
try {
UnsentMessageType unsentMessage = new UnsentMessageType();
unsentMessage.setDateReceived(timestamp);
unsentMessage.setSenderReceiver(senderReceiver);
unsentMessage.setRecipient(recipient);
unsentMessage.setMessage(message);
unsentMessage.getProperties().addAll(properties);
String createdUnsentMessageId = unsentModel.createMessage(unsentMessage, username);
List<String> unsentMessageIds = Arrays.asList(createdUnsentMessageId);
sendAuditLogMessageForCreateUnsentMessage(createdUnsentMessageId, username);
sendingQueueEvent.fire(new NotificationMessage("messageIds", unsentMessageIds));
return createdUnsentMessageId;
} catch (ExchangeModelException e) {
log.error("Couldn't add message to unsent list: {} {}", message, e);
throw new ExchangeLogException("Couldn't add message to unsent list");
}
}
use of eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageType in project UVMS-ExchangeModule-APP by UnionVMS.
the class UnsentModelBean method createMessage.
@Override
public String createMessage(UnsentMessageType message, String username) throws ExchangeModelException {
if (message == null) {
throw new InputArgumentException("No message to create");
}
try {
UnsentMessage entity = UnsentMessageMapper.toEntity(message, username);
UnsentMessage persistedEntity = dao.create(entity);
UnsentMessageType model = UnsentMessageMapper.toModel(persistedEntity);
return model.getMessageId();
} catch (ExchangeDaoException ex) {
LOG.error("[ Error when creating unsent message ] {}", ex.getMessage());
throw new ExchangeModelException("Error when creating unsent message ");
}
}
use of eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageType in project UVMS-ExchangeModule-APP by UnionVMS.
the class UnsentMessageMapper method toModel.
public static UnsentMessageType toModel(UnsentMessage entity) {
UnsentMessageType model = new UnsentMessageType();
model.setDateReceived(entity.getDateReceived());
model.setSenderReceiver(entity.getSenderReceiver());
model.setMessageId(entity.getGuid());
model.setRecipient(entity.getRecipient());
model.setMessage(entity.getMessage());
model.getProperties().addAll(mapToUnsentMessagePropertyModel(entity));
return model;
}
Aggregations