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());
}
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);
}
}
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.");
}
}
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;
}
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);
}
}
Aggregations