Search in sources :

Example 16 with ExchangeLogException

use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogMapper method getReceivedMovementExchangeLog.

public static ExchangeLogType getReceivedMovementExchangeLog(SetReportMovementType request, String typeRefGuid, String typeRefType, String username) throws ExchangeLogException {
    if (request == null) {
        throw new ExchangeLogException("No request");
    }
    ReceiveMovementType log = new ReceiveMovementType();
    log.setDateRecieved(request.getTimestamp());
    log.setType(LogType.RECEIVE_MOVEMENT);
    LogRefType logRefType = new LogRefType();
    logRefType.setRefGuid(typeRefGuid);
    TypeRefType refType = TypeRefType.UNKNOWN;
    try {
        refType = TypeRefType.fromValue(typeRefType);
    } catch (IllegalArgumentException e) {
        LOG.error("Non existing typeRefType: " + typeRefType);
    }
    logRefType.setType(refType);
    log.setTypeRef(logRefType);
    log.setStatus(ExchangeLogStatusTypeType.SUCCESSFUL);
    log.setSenderReceiver(getSenderReceiver(request.getMovement(), request.getPluginType(), request.getPluginName(), username));
    if (request.getMovement().getSource() != null) {
        log.setSource(request.getMovement().getSource().name());
    } else {
        log.setSource(request.getPluginType().name());
    }
    log.setRecipient(getRecipient(request.getMovement(), request.getPluginType()));
    return log;
}
Also used : TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType) ReceiveMovementType(eu.europa.ec.fisheries.schema.exchange.v1.ReceiveMovementType)

Example 17 with ExchangeLogException

use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogMapper method getRecipientOfPoll.

private static String getRecipientOfPoll(List<KeyValueType> pollReceiverList) throws ExchangeLogException {
    if (pollReceiverList == null || pollReceiverList.isEmpty()) {
        throw new ExchangeLogException("No poll receiver list");
    }
    String dnid = null;
    String memberNumber = null;
    String satelliteNumber = null;
    String les = null;
    for (KeyValueType pollReceiver : pollReceiverList) {
        if (IdType.DNID.name().equalsIgnoreCase(pollReceiver.getKey())) {
            dnid = pollReceiver.getValue();
        } else if (IdType.MEMBER_NUMBER.name().equalsIgnoreCase(pollReceiver.getKey())) {
            memberNumber = pollReceiver.getValue();
        } else if (IdType.SERIAL_NUMBER.name().equalsIgnoreCase(pollReceiver.getKey())) {
            satelliteNumber = pollReceiver.getValue();
        } else if (IdType.LES.name().equalsIgnoreCase(pollReceiver.getKey())) {
            les = pollReceiver.getValue();
        }
    }
    if (dnid != null && memberNumber != null) {
        return dnid + "." + memberNumber;
    } else if (satelliteNumber != null) {
        return satelliteNumber;
    } else if (les != null) {
        return les;
    }
    throw new ExchangeLogException("No receiver of poll");
}
Also used : ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) KeyValueType(eu.europa.ec.fisheries.schema.exchange.common.v1.KeyValueType)

Example 18 with ExchangeLogException

use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogMapper method getSendEmailExchangeLog.

private static ExchangeLogType getSendEmailExchangeLog(CommandType command) throws ExchangeLogException {
    if (command.getEmail() == null) {
        throw new ExchangeLogException("No email");
    }
    SendEmailType log = new SendEmailType();
    log.setType(LogType.SEND_EMAIL);
    log.setDateRecieved(command.getTimestamp());
    log.setSenderReceiver("SYSTEM");
    log.setRecipient(command.getEmail().getTo());
    log.setFwdRule(command.getFwdRule());
    log.setFwdDate(command.getTimestamp());
    return log;
}
Also used : SendEmailType(eu.europa.ec.fisheries.schema.exchange.v1.SendEmailType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)

Example 19 with ExchangeLogException

use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeEventIncomingServiceBean method processFluxFAResponseMessage.

@Override
public void processFluxFAResponseMessage(@Observes @ReceivedFluxFaResponseMessageEvent ExchangeMessageEvent message) {
    try {
        RcvFLUXFaResponseMessageRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), RcvFLUXFaResponseMessageRequest.class);
        log.debug("Got FLUXResponseMessage in exchange :" + request.getRequest());
        ExchangeLogType exchangeLogType = exchangeLog.log(request, LogType.RECEIVE_FLUX_RESPONSE_MSG, ExchangeLogStatusTypeType.ISSUED, TypeRefType.FA_RESPONSE, request.getRequest(), true);
        String msg = RulesModuleRequestMapper.createRcvFluxFaResponseMessageRequest(extractPluginType(request), request.getRequest(), request.getUsername(), extractLogId(message, exchangeLogType), request.getFluxDataFlow(), request.getSenderOrReceiver(), request.getOnValue());
        forwardToRules(msg, message, null);
    } catch (RulesModelMapperException | ExchangeModelMarshallException e) {
        log.error("Couldn't map to RcvFLUXFaResponseMessageRequest when processing FLUXResponseMessage coming from fa-plugin!", e);
    } catch (ExchangeLogException e) {
        log.error("Couldn't log FLUXResponseMessage received from plugin into database", e);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) RulesModelMapperException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException) RcvFLUXFaResponseMessageRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.RcvFLUXFaResponseMessageRequest)

Example 20 with ExchangeLogException

use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeEventIncomingServiceBean method receiveSalesReport.

@Override
public void receiveSalesReport(@Observes @ReceiveSalesReportEvent ExchangeMessageEvent event) {
    try {
        ReceiveSalesReportRequest request = JAXBMarshaller.unmarshallTextMessage(event.getJmsMessage(), ReceiveSalesReportRequest.class);
        log.info("Receive sales report in Exchange module:{}", request);
        String report = request.getReport();
        PluginType plugin = request.getPluginType();
        String sender = request.getSenderOrReceiver();
        String messageGuid = request.getMessageGuid();
        ExchangeLogType log = exchangeLog.log(request, LogType.RECEIVE_SALES_REPORT, ExchangeLogStatusTypeType.ISSUED, TypeRefType.SALES_REPORT, report, true);
        forwardToRules(RulesModuleRequestMapper.createReceiveSalesReportRequest(report, messageGuid, plugin.name(), log.getGuid(), sender, request.getOnValue()));
    } catch (ExchangeModelMarshallException e) {
        try {
            String errorMessage = "Couldn't map to SetSalesReportRequest when processing sales report from plugin. The event was " + event.getJmsMessage().getText();
            firePluginFault(event, errorMessage, e);
        } catch (JMSException e1) {
            firePluginFault(event, "Couldn't map to SetSalesReportRequest when processing sales report from plugin.", e);
        }
    } catch (ExchangeLogException e) {
        firePluginFault(event, "Could not log the incoming sales report.", e);
    } catch (RulesModelMarshallException e) {
        firePluginFault(event, "Could not create a request for the Rules module for an incoming sales report.", e);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) RulesModelMarshallException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ReceiveSalesReportRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveSalesReportRequest) JMSException(javax.jms.JMSException) PluginType(eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)

Aggregations

ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)33 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)15 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)14 NotificationMessage (eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)9 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)8 ExchangeMessageException (eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)7 JMSException (javax.jms.JMSException)6 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)5 LogRefType (eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)5 PluginType (eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)4 RulesModelMapperException (eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException)4 ServiceResponseType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType)3 UnsentMessageTypeProperty (eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageTypeProperty)3 RulesModelMarshallException (eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException)3 ArrayList (java.util.ArrayList)3 AcknowledgeType (eu.europa.ec.fisheries.schema.exchange.common.v1.AcknowledgeType)2 SetFAQueryMessageRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SetFAQueryMessageRequest)2 SetFLUXFAReportMessageRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SetFLUXFAReportMessageRequest)2 SetReportMovementType (eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType)2 ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)2