Search in sources :

Example 21 with ExchangeModelException

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

the class ExchangeServiceBean method registerService.

/**
 * {@inheritDoc}
 *
 * @param data
 * @throws ExchangeServiceException
 */
@Override
public ServiceResponseType registerService(ServiceType data, CapabilityListType capabilityList, SettingListType settingList, String username) throws ExchangeServiceException {
    LOG.info("Register service invoked in service layer: {} {}", data, username);
    try {
        ServiceResponseType serviceResponseType = serviceRegistryModel.registerService(data, capabilityList, settingList, username);
        sendAuditLogMessageForRegisterService(compressServiceClassName(serviceResponseType.getServiceClassName()), username);
        return serviceResponseType;
    } catch (ExchangeModelMapperException ex) {
        throw new ExchangeServiceException(ex.getMessage());
    } catch (ExchangeModelException e) {
        throw new ExchangeServiceException(e.getMessage());
    }
}
Also used : ExchangeModelMapperException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException) ServiceResponseType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Example 22 with ExchangeModelException

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

the class ExchangeLogServiceBeanTest method updateStatusByLogGuidWhenFailure.

@Test
public void updateStatusByLogGuidWhenFailure() throws Exception {
    expectedException.expect(ExchangeLogException.class);
    expectedException.expectMessage("Couldn't update the status of the exchange log with guid 12345. The new status should be FAILED");
    doThrow(new ExchangeModelException("noooooooooooooooooooo!!!")).when(exchangeLogModel).updateExchangeLogStatus(isA(ExchangeLogStatusType.class), eq("SYSTEM"));
    exchangeLogService.updateStatus("12345", ExchangeLogStatusTypeType.FAILED);
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) Test(org.junit.Test)

Example 23 with ExchangeModelException

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

the class ExchangeLogModelBean method updateExchangeLogStatus.

@Override
public ExchangeLogType updateExchangeLogStatus(ExchangeLogStatusType status, String username) throws ExchangeModelException {
    if (status == null || status.getGuid() == null || status.getGuid().isEmpty()) {
        throw new InputArgumentException("No exchange log to update status");
    }
    if (status.getHistory() == null || status.getHistory().isEmpty() || status.getHistory().size() != 1) {
        throw new InputArgumentException("Non valid status to update to");
    }
    try {
        ExchangeLogStatusHistoryType updateStatus = status.getHistory().get(0);
        ExchangeLog exchangeLog = logDao.getExchangeLogByGuid(status.getGuid());
        List<ExchangeLogStatus> statusList = exchangeLog.getStatusHistory();
        statusList.add(LogMapper.toNewStatusEntity(exchangeLog, updateStatus.getStatus(), username));
        exchangeLog.setStatus(updateStatus.getStatus());
        ExchangeLog retEntity = logDao.updateLog(exchangeLog);
        ExchangeLogType retType = LogMapper.toModel(retEntity);
        return retType;
    } catch (ExchangeDaoException ex) {
        LOG.error("[ Error when update status of Exchange log {} {}] {}", status, username, ex.getMessage());
        throw new ExchangeModelException("Error when update status of Exchange log", ex);
    }
}
Also used : InputArgumentException(eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException) ExchangeLogStatusHistoryType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType) ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog) ExchangeLogStatus(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)

Example 24 with ExchangeModelException

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

the class ExchangeLogModelBean method getExchangeLogStatusHistoryByQuery.

@Override
public List<ExchangeLogStatusType> getExchangeLogStatusHistoryByQuery(ExchangeHistoryListQuery query) throws ExchangeModelException {
    if (query == null) {
        throw new InputArgumentException("Exchange status list query is null");
    }
    try {
        List<ExchangeLogStatusType> logStatusHistoryList = new ArrayList<>();
        String sql = SearchFieldMapper.createSearchSql(query);
        List<ExchangeLogStatus> logList = logDao.getExchangeLogStatusHistory(sql, query);
        Set<String> uniqueExchangeLogGuid = new HashSet<>();
        Map<String, TypeRefType> logTypeMap = new HashMap<>();
        for (ExchangeLogStatus log : logList) {
            uniqueExchangeLogGuid.add(log.getLog().getGuid());
            logTypeMap.put(log.getLog().getGuid(), log.getLog().getTypeRefType());
        }
        // TODO not two db-calls?
        for (String guid : uniqueExchangeLogGuid) {
            ExchangeLog log = logDao.getExchangeLogByGuid(guid);
            ExchangeLogStatusType statusType = LogMapper.toStatusModel(log);
            logStatusHistoryList.add(statusType);
        }
        return logStatusHistoryList;
    } catch (ExchangeDaoException e) {
        LOG.error("[ Error when get Exchange log status history {}] {} ", query, e.getMessage());
        throw new ExchangeModelException("Error when get Exchange log status history ");
    }
}
Also used : InputArgumentException(eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExchangeLogStatus(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog) ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) HashSet(java.util.HashSet)

Example 25 with ExchangeModelException

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

the class ServiceRegistryModelBean method getPluginSettings.

@Override
public List<SettingType> getPluginSettings(String serviceClassName) throws ExchangeModelException {
    LOG.info("Get plugin settings:{}", serviceClassName);
    List<SettingType> settings = new ArrayList<>();
    try {
        List<ServiceSetting> entityList = dao.getServiceSettings(serviceClassName);
        for (ServiceSetting entity : entityList) {
            settings.add(ServiceMapper.toModel(entity));
        }
    } catch (ExchangeDaoException e) {
        LOG.error("[ Error when getting list. {}] {}", serviceClassName, e.getMessage());
        throw new ExchangeModelException("[ Error when getting list. ]");
    }
    return settings;
}
Also used : ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) ArrayList(java.util.ArrayList) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) ServiceSetting(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting)

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