Search in sources :

Example 36 with ExchangeLogType

use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogServiceBean method log.

@Override
public ExchangeLogType log(ExchangeBaseRequest request, LogType logType, ExchangeLogStatusTypeType status, TypeRefType messageType, String messageText, boolean incoming) throws ExchangeLogException {
    LogRefType ref = new LogRefType();
    ref.setMessage(messageText);
    ref.setRefGuid(request.getMessageGuid());
    ref.setType(messageType);
    ExchangeLogType log = new ExchangeLogType();
    log.setSenderReceiver(request.getSenderOrReceiver());
    log.setDateRecieved(request.getDate());
    log.setType(logType);
    log.setStatus(status);
    log.setIncoming(incoming);
    log.setTypeRef(ref);
    log.setDestination(request.getDestination());
    return log(log, request.getUsername());
}
Also used : ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)

Example 37 with ExchangeLogType

use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType 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 38 with ExchangeLogType

use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType 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 39 with ExchangeLogType

use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogMapper method getPollExchangeLog.

private static ExchangeLogType getPollExchangeLog(CommandType command) throws ExchangeLogException {
    if (command.getPoll() == null) {
        throw new ExchangeLogException("No poll");
    }
    // TODO fix in mobileterminal
    SendPollType log = new SendPollType();
    log.setType(LogType.SEND_POLL);
    log.setDateRecieved(command.getTimestamp());
    log.setRecipient(getRecipientOfPoll(command.getPoll().getPollReceiver()));
    log.setSenderReceiver("System");
    LogRefType logRefType = new LogRefType();
    logRefType.setRefGuid(command.getPoll().getPollId());
    logRefType.setType(TypeRefType.POLL);
    log.setFwdDate(command.getTimestamp());
    log.setTypeRef(logRefType);
    return log;
}
Also used : SendPollType(eu.europa.ec.fisheries.schema.exchange.v1.SendPollType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)

Example 40 with ExchangeLogType

use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogModelBean method updateExchangeLogStatus.

@Override
public ExchangeLogType updateExchangeLogStatus(ExchangeLogStatusType status, String username) throws ExchangeModelException {
    if (status == null || status.getGuid() == null || status.getGuid().isEmpty()) {
        throw new InputArgumentException("No exchange log to update status");
    }
    if (status.getHistory() == null || status.getHistory().isEmpty() || status.getHistory().size() != 1) {
        throw new InputArgumentException("Non valid status to update to");
    }
    try {
        ExchangeLogStatusHistoryType updateStatus = status.getHistory().get(0);
        ExchangeLog exchangeLog = logDao.getExchangeLogByGuid(status.getGuid());
        List<ExchangeLogStatus> statusList = exchangeLog.getStatusHistory();
        statusList.add(LogMapper.toNewStatusEntity(exchangeLog, updateStatus.getStatus(), username));
        exchangeLog.setStatus(updateStatus.getStatus());
        ExchangeLog retEntity = logDao.updateLog(exchangeLog);
        ExchangeLogType retType = LogMapper.toModel(retEntity);
        return retType;
    } catch (ExchangeDaoException ex) {
        LOG.error("[ Error when update status of Exchange log {} {}] {}", status, username, ex.getMessage());
        throw new ExchangeModelException("Error when update status of Exchange log", ex);
    }
}
Also used : InputArgumentException(eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException) ExchangeLogStatusHistoryType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType) ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog) ExchangeLogStatus(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)

Aggregations

ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)43 ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)27 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)19 Test (org.junit.Test)19 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)18 Date (java.util.Date)17 LogRefType (eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)13 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)9 TypeRefType (eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType)8 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)8 ExchangeDaoException (eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException)5 NotificationMessage (eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)5 JMSException (javax.jms.JMSException)5 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException)4 ArrayList (java.util.ArrayList)4 PluginType (eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)3 SendEmailType (eu.europa.ec.fisheries.schema.exchange.v1.SendEmailType)3 SendMovementType (eu.europa.ec.fisheries.schema.exchange.v1.SendMovementType)3 SendPollType (eu.europa.ec.fisheries.schema.exchange.v1.SendPollType)3 ExchangeLogStatus (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)3