Search in sources :

Example 1 with NoEntityFoundException

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");
    }
}
Also used : UnsentMessageType(eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageType) InputArgumentException(eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException) ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) NoEntityFoundException(eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException) ArrayList(java.util.ArrayList) UnsentMessage(eu.europa.ec.fisheries.uvms.exchange.entity.unsent.UnsentMessage) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)

Example 2 with NoEntityFoundException

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. ] ");
    }
}
Also used : ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) NoEntityFoundException(eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException) NoResultException(javax.persistence.NoResultException) NoResultException(javax.persistence.NoResultException) NoEntityFoundException(eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException) ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) PersistenceException(javax.persistence.PersistenceException) Session(org.hibernate.Session)

Example 3 with NoEntityFoundException

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. ] ");
    }
}
Also used : ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) NoEntityFoundException(eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException) NoResultException(javax.persistence.NoResultException) NoResultException(javax.persistence.NoResultException) NoEntityFoundException(eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException) ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) PersistenceException(javax.persistence.PersistenceException) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)

Example 4 with NoEntityFoundException

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. ]");
    }
}
Also used : NoEntityFoundException(eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException) UnsentMessage(eu.europa.ec.fisheries.uvms.exchange.entity.unsent.UnsentMessage) NoResultException(javax.persistence.NoResultException)

Aggregations

NoEntityFoundException (eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException)4 ExchangeDaoException (eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException)3 NoResultException (javax.persistence.NoResultException)3 UnsentMessage (eu.europa.ec.fisheries.uvms.exchange.entity.unsent.UnsentMessage)2 PersistenceException (javax.persistence.PersistenceException)2 UnsentMessageType (eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageType)1 ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)1 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)1 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException)1 ArrayList (java.util.ArrayList)1 Session (org.hibernate.Session)1