Search in sources :

Example 6 with ExchangeServiceException

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

the class PluginServiceBean method updatePluginSetting.

@Override
public void updatePluginSetting(@Observes @UpdatePluginSettingEvent ExchangeMessageEvent settingEvent) {
    LOG.info("update plugin setting from module queue:{}", settingEvent);
    try {
        TextMessage jmsMessage = settingEvent.getJmsMessage();
        UpdatePluginSettingRequest request = JAXBMarshaller.unmarshallTextMessage(jmsMessage, UpdatePluginSettingRequest.class);
        updatePluginSetting(request.getServiceClassName(), request.getSetting(), request.getUsername());
        String text = ExchangeModuleResponseMapper.mapUpdateSettingResponse(ExchangeModuleResponseMapper.mapAcknowledgeTypeOK());
        producer.sendModuleResponseMessage(settingEvent.getJmsMessage(), text);
    } catch (ExchangeModelMarshallException | ExchangeServiceException | ExchangeMessageException e) {
        LOG.error("Couldn't unmarshall update setting request");
        settingEvent.setErrorFault(ExchangeModuleResponseMapper.createFaultMessage(FaultCode.EXCHANGE_EVENT_SERVICE, "Couldn't update plugin setting"));
        producer.sendModuleErrorResponseMessage(settingEvent);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) UpdatePluginSettingRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.UpdatePluginSettingRequest) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) TextMessage(javax.jms.TextMessage) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Example 7 with ExchangeServiceException

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

the class PluginServiceBean method start.

@Override
public boolean start(String serviceClassName) throws ExchangeServiceException {
    if (serviceClassName == null) {
        throw new InputArgumentException("No service to start");
    }
    try {
        if (isServiceRegistered(serviceClassName)) {
            String text = ExchangePluginRequestMapper.createStartRequest();
            producer.sendEventBusMessage(text, serviceClassName);
            return true;
        } else {
            throw new ExchangeServiceException("Service with service class name: " + serviceClassName + " does not exist");
        }
    } catch (ExchangeModelMarshallException e) {
        throw new ExchangeServiceException("[ Couldn't map start request for " + serviceClassName + " ]");
    } catch (ExchangeMessageException e) {
        throw new ExchangeServiceException("[ Couldn't send start request for " + serviceClassName + " ]");
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) InputArgumentException(eu.europa.ec.fisheries.uvms.exchange.service.exception.InputArgumentException) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Example 8 with ExchangeServiceException

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

the class ExchangeAssetServiceBean method getAsset.

@Override
public Asset getAsset(String assetGuid) throws ExchangeServiceException {
    try {
        String request = AssetModuleRequestMapper.createGetAssetModuleRequest(assetGuid, AssetIdType.GUID);
        String messageId = producer.sendMessageOnQueue(request, MessageQueue.VESSEL);
        TextMessage response = consumer.getMessage(messageId, TextMessage.class);
        return AssetModuleResponseMapper.mapToAssetFromResponse(response, messageId);
    } catch (ExchangeMessageException e) {
        LOG.error("Couldn't send message to vessel module");
        throw new ExchangeServiceException("Couldn't send message to vessel module");
    } catch (AssetModelMapperException e) {
        LOG.error("Couldn't map asset object by guid:  {}", assetGuid);
        throw new ExchangeServiceException("Couldn't map asset object by guid:  " + assetGuid);
    }
}
Also used : AssetModelMapperException(eu.europa.ec.fisheries.uvms.asset.model.exception.AssetModelMapperException) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) TextMessage(javax.jms.TextMessage) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Example 9 with ExchangeServiceException

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

the class ExchangeEventIncomingServiceBean method processAcknowledge.

@Override
public void processAcknowledge(@Observes @ExchangeLogEvent ExchangeMessageEvent message) {
    log.info("Process acknowledge:{}", message);
    try {
        AcknowledgeResponse response = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), AcknowledgeResponse.class);
        AcknowledgeType acknowledge = response.getResponse();
        String serviceClassName = response.getServiceClassName();
        ExchangePluginMethod method = response.getMethod();
        switch(method) {
            case SET_COMMAND:
                // Only Acknowledge for poll should have a poll status set
                if (acknowledge.getPollStatus() != null && acknowledge.getPollStatus().getPollId() != null) {
                    handleSetPollStatusAcknowledge(method, serviceClassName, acknowledge);
                } else {
                    handleUpdateExchangeLogAcknowledge(method, serviceClassName, acknowledge);
                }
                break;
            case SET_REPORT:
                handleUpdateExchangeLogAcknowledge(method, serviceClassName, acknowledge);
                break;
            case START:
                handleUpdateServiceAcknowledge(serviceClassName, acknowledge, StatusType.STARTED);
                pluginStatusEvent.fire(createNotificationMessage(serviceClassName, true));
                break;
            case STOP:
                handleUpdateServiceAcknowledge(serviceClassName, acknowledge, StatusType.STOPPED);
                pluginStatusEvent.fire(createNotificationMessage(serviceClassName, false));
                break;
            case SET_CONFIG:
            default:
                handleAcknowledge(method, serviceClassName, acknowledge);
                break;
        }
    } catch (ExchangeModelMarshallException e) {
        log.error("Process acknowledge couldn't be marshalled {} {}", message, e);
    } catch (ExchangeServiceException e) {
        // TODO Audit.log() couldn't process acknowledge in exchange service
        log.error("Couldn't process acknowledge in exchange service:{} {} ", message, e.getMessage());
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) ExchangePluginMethod(eu.europa.ec.fisheries.schema.exchange.plugin.v1.ExchangePluginMethod) AcknowledgeType(eu.europa.ec.fisheries.schema.exchange.common.v1.AcknowledgeType) AcknowledgeResponse(eu.europa.ec.fisheries.schema.exchange.plugin.v1.AcknowledgeResponse) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Example 10 with ExchangeServiceException

use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException 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)

Aggregations

ExchangeServiceException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)15 ServiceResponseType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType)8 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)8 ExchangeMessageException (eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)6 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)4 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.service.exception.InputArgumentException)3 TextMessage (javax.jms.TextMessage)3 PluginType (eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)2 SettingType (eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType)2 ConfigServiceException (eu.europa.ec.fisheries.uvms.config.exception.ConfigServiceException)2 ExchangeModelMapperException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException)2 AcknowledgeType (eu.europa.ec.fisheries.schema.exchange.common.v1.AcknowledgeType)1 SetMovementReportRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SetMovementReportRequest)1 UpdatePluginSettingRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.UpdatePluginSettingRequest)1 MovementBaseType (eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementBaseType)1 AcknowledgeResponse (eu.europa.ec.fisheries.schema.exchange.plugin.v1.AcknowledgeResponse)1 ExchangePluginMethod (eu.europa.ec.fisheries.schema.exchange.plugin.v1.ExchangePluginMethod)1 UnregisterServiceRequest (eu.europa.ec.fisheries.schema.exchange.registry.v1.UnregisterServiceRequest)1 SettingListType (eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType)1 ProcessedMovementAck (eu.europa.ec.fisheries.schema.movement.module.v1.ProcessedMovementAck)1