Search in sources :

Example 6 with NotificationMessage

use of eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogServiceBean method setPollStatus.

@Override
public PollStatus setPollStatus(String jmsCorrelationId, String pollId, ExchangeLogStatusTypeType logStatus, String username) throws ExchangeLogException {
    try {
        // Remove the message from cache, because legancy implementation
        logCache.acknowledged(jmsCorrelationId);
        PollStatus pollStatus = new PollStatus();
        pollStatus.setPollGuid(pollId);
        pollStatus.setStatus(logStatus);
        ExchangeLogType exchangeLogType = exchangeLogModel.setPollStatus(pollStatus, username);
        pollStatus.setExchangeLogGuid(exchangeLogType.getGuid());
        sendAuditLogMessageForUpdatePollStatus(pollId, username);
        // For long polling
        exchangeLogEvent.fire(new NotificationMessage("guid", pollStatus.getExchangeLogGuid()));
        return pollStatus;
    } catch (ExchangeModelMapperException e) {
        throw new ExchangeLogException("Couldn't update status of exchange log");
    } catch (ExchangeModelException e) {
        throw new ExchangeLogException("Couldn't update status of exchange log");
    }
}
Also used : PollStatus(eu.europa.ec.fisheries.schema.exchange.v1.PollStatus) ExchangeModelMapperException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException) NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)

Example 7 with NotificationMessage

use of eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage 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");
    }
}
Also used : UnsentMessageType(eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageType) NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)

Example 8 with NotificationMessage

use of eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogServiceBean method updateStatus.

@Override
public ExchangeLogType updateStatus(String pluginMessageId, ExchangeLogStatusTypeType logStatus, String username) throws ExchangeLogException {
    try {
        String logGuid = logCache.acknowledged(pluginMessageId);
        ExchangeLogStatusType exchangeLogStatusType = createExchangeLogStatusType(logStatus, logGuid);
        ExchangeLogType updatedLog = exchangeLogModel.updateExchangeLogStatus(exchangeLogStatusType, username);
        sendAuditLogMessageForUpdateExchangeLog(updatedLog.getGuid(), username);
        // For long polling
        exchangeLogEvent.fire(new NotificationMessage("guid", updatedLog.getGuid()));
        return updatedLog;
    } catch (ExchangeModelException e) {
        throw new ExchangeLogException("Couldn't update status of exchange log", e);
    }
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)

Example 9 with NotificationMessage

use of eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogServiceBean method log.

@Override
public ExchangeLogType log(ExchangeLogType log, String username) throws ExchangeLogException {
    try {
        ExchangeLogType exchangeLog = exchangeLogModel.createExchangeLog(log, username);
        String guid = exchangeLog.getGuid();
        sendAuditLogMessageForCreateExchangeLog(guid, username);
        exchangeLogEvent.fire(new NotificationMessage("guid", guid));
        LOG.debug("[INFO] Logging message with guid : [ " + guid + " ]..");
        return exchangeLog;
    } catch (ExchangeModelException e) {
        throw new ExchangeLogException("Couldn't create log exchange log.");
    }
}
Also used : NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)

Example 10 with NotificationMessage

use of eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogServiceBean method removeUnsentMessage.

@Override
public void removeUnsentMessage(String unsentMessageId, String username) throws ExchangeLogException {
    log.debug("removeUnsentMessage in service layer:{}", unsentMessageId);
    try {
        String removeMessageId = unsentModel.removeMessage(unsentMessageId);
        List<String> removedMessageIds = Arrays.asList(removeMessageId);
        sendAuditLogMessageForRemoveUnsentMessage(removeMessageId, username);
        sendingQueueEvent.fire(new NotificationMessage("messageIds", removedMessageIds));
    } catch (ExchangeModelException e) {
        log.error("Couldn't add message to unsent list {} {}", unsentMessageId, e);
        throw new ExchangeLogException("Couldn't add message to unsent list");
    }
}
Also used : NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)

Aggregations

NotificationMessage (eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)10 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)9 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)6 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)5 LogRefType (eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)2 PollStatus (eu.europa.ec.fisheries.schema.exchange.v1.PollStatus)2 UnsentMessageType (eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageType)2 ProcessedMovementResponse (eu.europa.ec.fisheries.schema.exchange.module.v1.ProcessedMovementResponse)1 MovementRefType (eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementRefType)1 SetReportMovementType (eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType)1 ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)1 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)1 ExchangeMessageException (eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)1 ExchangeModelMapperException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException)1 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)1