Search in sources :

Example 26 with ExchangeModelException

use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException in project UVMS-ExchangeModule-APP by UnionVMS.

the class ServiceRegistryModelBean method updatePluginStatus.

@Override
public ServiceResponseType updatePluginStatus(String serviceName, StatusType status, String username) throws ExchangeModelException {
    Service service = dao.getServiceByServiceClassName(serviceName);
    if (service != null) {
        service.setStatus(status.name());
        service.setUpdatedBy(username);
        service.setUpdated(new Date());
        return ServiceMapper.toServiceModel(dao.updateService(service));
    }
    throw new ExchangeModelException("[ Error when update plugin " + serviceName + " with status " + status.name());
}
Also used : Service(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) Date(java.util.Date)

Example 27 with ExchangeModelException

use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException 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 ");
    }
}
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) UnsentMessage(eu.europa.ec.fisheries.uvms.exchange.entity.unsent.UnsentMessage) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)

Example 28 with ExchangeModelException

use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException 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 ");
    }
}
Also used : InputArgumentException(eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException) ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) UnsentMessage(eu.europa.ec.fisheries.uvms.exchange.entity.unsent.UnsentMessage) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)

Aggregations

ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)28 ExchangeDaoException (eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException)12 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException)10 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)9 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)8 ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)7 NotificationMessage (eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)6 ArrayList (java.util.ArrayList)6 ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)5 ServiceResponseType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType)4 TypeRefType (eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType)4 UnsentMessageType (eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageType)4 ExchangeServiceException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)4 ExchangeLogStatus (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)3 UnsentMessage (eu.europa.ec.fisheries.uvms.exchange.entity.unsent.UnsentMessage)3 ExchangeSearchMapperException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeSearchMapperException)3 ParseException (java.text.ParseException)3 ListResponseDto (eu.europa.ec.fisheries.uvms.exchange.model.dto.ListResponseDto)2 ExchangeModelMapperException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException)2 JMSException (javax.jms.JMSException)2