use of eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ServiceRegistryModelBean method unregisterService.
@Override
public ServiceResponseType unregisterService(ServiceType serviceType, String username) throws ExchangeModelException {
// Look for existing service
Service service = dao.getServiceByServiceClassName(serviceType.getServiceClassName());
ServiceResponseType response = null;
if (service != null) {
service.setActive(false);
service.setStatus(StatusType.STOPPED.name());
service.getServiceCapabilityList().clear();
service.getServiceSettingList().clear();
service.setUpdatedBy(username);
Service updateService = dao.updateService(service);
response = ServiceMapper.toServiceModel(updateService);
}
if (response != null) {
return response;
}
// TODO handle unable to unregister
throw new ExchangeDaoException("[ No service to unregister ]");
}
use of eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException in project UVMS-ExchangeModule-APP by UnionVMS.
the class UnsentModelBean method createMessage.
@Override
public String createMessage(UnsentMessageType message, String username) throws ExchangeModelException {
if (message == null) {
throw new InputArgumentException("No message to create");
}
try {
UnsentMessage entity = UnsentMessageMapper.toEntity(message, username);
UnsentMessage persistedEntity = dao.create(entity);
UnsentMessageType model = UnsentMessageMapper.toModel(persistedEntity);
return model.getMessageId();
} catch (ExchangeDaoException ex) {
LOG.error("[ Error when creating unsent message ] {}", ex.getMessage());
throw new ExchangeModelException("Error when creating unsent message ");
}
}
use of eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException in project UVMS-ExchangeModule-APP by UnionVMS.
the class UnsentModelBean method removeMessage.
@Override
public String removeMessage(String unsentMessageId) throws ExchangeModelException {
if (unsentMessageId == null) {
throw new InputArgumentException("No message to remove");
}
try {
UnsentMessage entity = dao.getByGuid(unsentMessageId);
if (entity != null) {
String guid = entity.getGuid();
dao.remove(entity);
return guid;
} else {
LOG.error("[ Error when removing unsent message ]");
throw new ExchangeModelException("Error when removing unsent message ");
}
} catch (ExchangeDaoException ex) {
LOG.error("[ Error when creating unsent message ] {}", ex.getMessage());
throw new ExchangeModelException("Error when creating unsent message ");
}
}
use of eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogDaoBean method getExchangeLogListPaginated.
@Override
public List<ExchangeLog> getExchangeLogListPaginated(Integer page, Integer listSize, String sql, List<SearchValue> searchKeyValues) throws ExchangeDaoException {
try {
LOG.debug("SQL QUERY IN LIST PAGINATED: " + sql);
TypedQuery<ExchangeLog> query = em.createQuery(sql, ExchangeLog.class);
HashMap<ExchangeSearchField, List<SearchValue>> orderedValues = SearchFieldMapper.combineSearchFields(searchKeyValues);
setQueryParameters(query, orderedValues);
query.setFirstResult(listSize * (page - 1));
query.setMaxResults(listSize);
return query.getResultList();
} catch (IllegalArgumentException e) {
LOG.error("[ Error getting exchangelog list paginated ] {}", e.getMessage());
throw new ExchangeDaoException("[ Error when getting list ] ");
} catch (Exception e) {
LOG.error("[ Error getting exchangelog list paginated ] {}", e.getMessage());
throw new ExchangeDaoException("[ Error when getting list ] ");
}
}
use of eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException 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. ] ");
}
}
Aggregations