Search in sources :

Example 1 with ExchangeModelMapperException

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

the class ExchangeLogServiceBean method setPollStatus.

@Override
public PollStatus setPollStatus(String jmsCorrelationId, String pollId, ExchangeLogStatusTypeType logStatus, String username) throws ExchangeLogException {
    try {
        // Remove the message from cache, because legancy implementation
        logCache.acknowledged(jmsCorrelationId);
        PollStatus pollStatus = new PollStatus();
        pollStatus.setPollGuid(pollId);
        pollStatus.setStatus(logStatus);
        ExchangeLogType exchangeLogType = exchangeLogModel.setPollStatus(pollStatus, username);
        pollStatus.setExchangeLogGuid(exchangeLogType.getGuid());
        sendAuditLogMessageForUpdatePollStatus(pollId, username);
        // For long polling
        exchangeLogEvent.fire(new NotificationMessage("guid", pollStatus.getExchangeLogGuid()));
        return pollStatus;
    } catch (ExchangeModelMapperException e) {
        throw new ExchangeLogException("Couldn't update status of exchange log");
    } catch (ExchangeModelException e) {
        throw new ExchangeLogException("Couldn't update status of exchange log");
    }
}
Also used : PollStatus(eu.europa.ec.fisheries.schema.exchange.v1.PollStatus) ExchangeModelMapperException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException) NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)

Example 2 with ExchangeModelMapperException

use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException 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 3 with ExchangeModelMapperException

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

the class PluginServiceBean method registerService.

private void registerService(RegisterServiceRequest register, String messageId) throws ExchangeModelMarshallException, ExchangeMessageException {
    try {
        overrideSettingsFromConfig(register);
        ServiceResponseType service = exchangeService.registerService(register.getService(), register.getCapabilityList(), register.getSettingList(), register.getService().getName());
        // push to config module
        try {
            String serviceClassName = register.getService().getServiceClassName();
            SettingListType settings = register.getSettingList();
            for (SettingType setting : settings.getSetting()) {
                String description = "Plugin " + serviceClassName + " " + setting.getKey() + " setting";
                configService.pushSettingToConfig(SettingTypeMapper.map(setting.getKey(), setting.getValue(), description), false);
            }
        } catch (ConfigServiceException e) {
            LOG.error("Couldn't register plugin settings in config parameter table");
        }
        // TODO log to exchange log
        String response = ExchangePluginResponseMapper.mapToRegisterServiceResponseOK(messageId, service);
        producer.sendEventBusMessage(response, register.getService().getServiceResponseMessageName());
        setServiceStatusOnRegister(register.getService().getServiceClassName());
    } catch (ExchangeServiceException | ExchangeModelMapperException e) {
        String response = ExchangePluginResponseMapper.mapToRegisterServiceResponseNOK(messageId, "Exchange service exception when registering plugin [ " + e.getMessage() + " ]");
        producer.sendEventBusMessage(response, register.getService().getServiceResponseMessageName());
    }
}
Also used : ExchangeModelMapperException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException) ServiceResponseType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType) ConfigServiceException(eu.europa.ec.fisheries.uvms.config.exception.ConfigServiceException) SettingType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType) SettingListType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Aggregations

ExchangeModelMapperException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException)3 ServiceResponseType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType)2 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)2 ExchangeServiceException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)2 SettingListType (eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType)1 SettingType (eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType)1 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)1 PollStatus (eu.europa.ec.fisheries.schema.exchange.v1.PollStatus)1 ConfigServiceException (eu.europa.ec.fisheries.uvms.config.exception.ConfigServiceException)1 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)1 NotificationMessage (eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)1