use of eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException in project UVMS-ExchangeModule-APP by UnionVMS.
the class UnsentModelBean method resend.
@Override
public List<UnsentMessageType> resend(List<String> unsentMessageId) throws ExchangeModelException {
if (unsentMessageId == null) {
throw new InputArgumentException("No messageList to resend");
}
try {
List<UnsentMessageType> unsentMessageList = new ArrayList<>();
for (String messageId : unsentMessageId) {
try {
UnsentMessage message = dao.getByGuid(messageId);
UnsentMessage removedMessage = dao.remove(message);
unsentMessageList.add(UnsentMessageMapper.toModel(removedMessage));
} catch (NoEntityFoundException e) {
LOG.error("Couldn't find message to resend with guid: " + messageId);
}
}
return unsentMessageList;
} catch (ExchangeDaoException ex) {
LOG.error("[ Error when resending message message list ] {}", ex.getMessage());
throw new ExchangeModelException("Error when resending unsent message list");
}
}
use of eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogDaoBean method getExchangeLogByTypesRefAndGuid.
@Override
public List<ExchangeLog> getExchangeLogByTypesRefAndGuid(String typeRefGuid, List<TypeRefType> types) throws ExchangeDaoException {
try {
org.hibernate.Query namedQuery = getEm().unwrap(Session.class).getNamedQuery(ExchangeConstants.LOG_BY_TYPE_REF_AND_GUID);
namedQuery.setParameter("typeRefGuid", typeRefGuid);
namedQuery.setParameterList("typeRefTypes", types);
return namedQuery.list();
} catch (NoResultException e) {
LOG.error("[ Error when getting entity by type ref ID. ] {}", e.getMessage());
throw new NoEntityFoundException("[ Error when getting entity by type ref ID. ]");
} catch (Exception e) {
LOG.error("[ Error when getting entity by type ref ID. ] {}", e.getMessage());
throw new ExchangeDaoException("[ Error when getting entity by type ref ID. ] ");
}
}
use of eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogDaoBean method getExchangeLogByGuid.
@Override
public ExchangeLog getExchangeLogByGuid(String logGuid, TypeRefType typeRefType) throws ExchangeDaoException {
try {
TypedQuery<ExchangeLog> query = em.createNamedQuery(ExchangeConstants.LOG_BY_GUID, ExchangeLog.class);
query.setParameter("typeRefType", typeRefType);
query.setParameter("guid", logGuid);
return query.getSingleResult();
} catch (NoResultException e) {
LOG.error("[ Error when getting entity by ID. ] {}", e.getMessage());
throw new NoEntityFoundException("[ Error when getting entity by ID. ]");
} catch (Exception e) {
LOG.error("[ Error when getting entity by ID. ] {}", e.getMessage());
throw new ExchangeDaoException("[ Error when getting entity by ID. ] ");
}
}
use of eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException in project UVMS-ExchangeModule-APP by UnionVMS.
the class UnsentMessageDaoBean method getByGuid.
@Override
public UnsentMessage getByGuid(String guid) throws NoEntityFoundException {
try {
TypedQuery<UnsentMessage> query = em.createNamedQuery(ExchangeConstants.UNSENT_BY_GUID, UnsentMessage.class);
query.setParameter("guid", guid);
return query.getSingleResult();
} catch (NoResultException e) {
LOG.error("[ Error when getting entity by ID. ] {}", e.getMessage());
throw new NoEntityFoundException("[ Error when getting entity by ID. ]");
}
}
Aggregations