use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method logRefIdByTypeExists.
@Override
public void logRefIdByTypeExists(@Observes @LogRefIdByTypeExists ExchangeMessageEvent event) {
try {
LogRefIdByTypeExistsRequest request = unMarshallMessage(event.getJmsMessage().getText(), LogRefIdByTypeExistsRequest.class);
String refGuid = request.getRefGuid();
List<TypeRefType> refTypes = request.getRefTypes();
List<ExchangeLogStatusType> exchangeStatusHistoryList = exchangeLogModel.getExchangeLogsStatusHistories(refGuid, refTypes);
LogRefIdByTypeExistsResponse response = new LogRefIdByTypeExistsResponse();
if (CollectionUtils.isNotEmpty(exchangeStatusHistoryList)) {
response.setRefGuid(exchangeStatusHistoryList.get(0).getTypeRef().getRefGuid());
}
String responseAsString = JAXBUtils.marshallJaxBObjectToString(response);
producer.sendModuleResponseMessage(event.getJmsMessage(), responseAsString);
} catch (ExchangeModelException | JAXBException | JMSException e) {
fireExchangeFault(event, "Could not un-marshall " + LogRefIdByTypeExistsRequest.class, e);
}
}
use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method logIdByTypeExists.
@Override
public void logIdByTypeExists(@Observes @LogIdByTypeExists ExchangeMessageEvent event) {
try {
LogIdByTypeExistsRequest request = unMarshallMessage(event.getJmsMessage().getText(), LogIdByTypeExistsRequest.class);
String messageGuid = request.getMessageGuid();
TypeRefType refType = request.getRefType();
ExchangeLogType exchangeLogByGuid = exchangeLogModel.getExchangeLogByGuidAndType(messageGuid, refType);
LogIdByTypeExistsResponse response = new LogIdByTypeExistsResponse();
if (exchangeLogByGuid != null) {
response.setMessageGuid(exchangeLogByGuid.getGuid());
}
String responseAsString = JAXBUtils.marshallJaxBObjectToString(response);
producer.sendModuleResponseMessage(event.getJmsMessage(), responseAsString);
} catch (ExchangeModelException | JAXBException | JMSException e) {
fireExchangeFault(event, "Could not un-marshall " + LogRefIdByTypeExistsRequest.class, e);
}
}
use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogServiceBean method getExchangeStatusHistoryList.
@Override
public List<ExchangeLogStatusType> getExchangeStatusHistoryList(ExchangeLogStatusTypeType status, TypeRefType type, Date from, Date to) throws ExchangeLogException {
log.info("Get pollstatus list in service layer:{}", status);
try {
List<ExchangeLogStatusTypeType> statusList = new ArrayList<>();
if (status != null) {
statusList.add(status);
}
List<TypeRefType> typeList = new ArrayList<>();
if (type != null) {
typeList.add(type);
}
ExchangeHistoryListQuery query = new ExchangeHistoryListQuery();
query.setTypeRefDateFrom(from);
query.setTypeRefDateTo(to);
query.getStatus().addAll(statusList);
query.getType().addAll(typeList);
List<ExchangeLogStatusType> pollStatusList = exchangeLogModel.getExchangeLogStatusHistoryByQuery(query);
return pollStatusList;
} catch (ExchangeModelException e) {
throw new ExchangeLogException("Couldn't get exchange status history list.");
}
}
use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogServiceBean method getExchangeLogList.
@Override
public GetLogListByQueryResponse getExchangeLogList(ExchangeListQuery query) throws ExchangeLogException {
GetLogListByQueryResponse response = new GetLogListByQueryResponse();
try {
ListResponseDto exchangeLogList = exchangeLogModel.getExchangeLogListByQuery(query);
response.setCurrentPage(exchangeLogList.getCurrentPage());
response.setTotalNumberOfPages(exchangeLogList.getTotalNumberOfPages());
response.getExchangeLog().addAll(exchangeLogList.getExchangeLogList());
return response;
} catch (ExchangeModelException e) {
throw new ExchangeLogException("Couldn't get exchange log list.");
}
}
use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException 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);
}
}
}
}
Aggregations