Search in sources :

Example 1 with ExchangeServiceException

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

the class ExchangeEventIncomingServiceBean method processMovement.

@Override
public void processMovement(@Observes @SetMovementEvent ExchangeMessageEvent message) {
    try {
        final TextMessage jmsMessage = message.getJmsMessage();
        final String jmsMessageID = jmsMessage.getJMSMessageID();
        SetMovementReportRequest request = JAXBMarshaller.unmarshallTextMessage(jmsMessage, SetMovementReportRequest.class);
        log.info("[INFO] Processing Movement : {}", request);
        String username;
        SetReportMovementType setRepMovType = request.getRequest();
        if (MovementSourceType.MANUAL.equals(setRepMovType.getMovement().getSource())) {
            // A person has created a position
            username = request.getUsername();
            // Send some response to Movement, if it originated from there (manual movement)
            ProcessedMovementAck response = MovementModuleResponseMapper.mapProcessedMovementAck(eu.europa.ec.fisheries.schema.movement.common.v1.AcknowledgeTypeType.OK, jmsMessageID, "Movement successfully processed");
            producer.sendModuleAckMessage(jmsMessageID, MessageQueue.MOVEMENT_RESPONSE, JAXBMarshaller.marshallJaxBObjectToString(response));
        } else {
            // A plugin has reported a position
            username = setRepMovType.getPluginType().name();
        }
        String pluginName = setRepMovType.getPluginName();
        ServiceResponseType service = exchangeService.getService(pluginName);
        PluginType pluginType = setRepMovType.getPluginType();
        if (validate(setRepMovType, service, jmsMessage)) {
            MovementBaseType baseMovement = setRepMovType.getMovement();
            RawMovementType rawMovement = MovementMapper.getInstance().getMapper().map(baseMovement, RawMovementType.class);
            final AssetId assetId = rawMovement.getAssetId();
            if (assetId != null && assetId.getAssetIdList() != null) {
                assetId.getAssetIdList().addAll(MovementMapper.mapAssetIdList(baseMovement.getAssetId().getAssetIdList()));
            }
            if (baseMovement.getMobileTerminalId() != null && baseMovement.getMobileTerminalId().getMobileTerminalIdList() != null) {
                rawMovement.getMobileTerminal().getMobileTerminalIdList().addAll(MovementMapper.mapMobileTerminalIdList(baseMovement.getMobileTerminalId().getMobileTerminalIdList()));
            }
            rawMovement.setPluginType(pluginType.value());
            rawMovement.setPluginName(pluginName);
            rawMovement.setDateRecieved(setRepMovType.getTimestamp());
            // TODO : Temporary - probably better to change corr id to have the same though the entire flow;
            // TODO : then we can use this to send response to original caller from anywhere needed
            rawMovement.setAckResponseMessageID(jmsMessageID);
            log.info("[INFO] Logging received movement.");
            exchangeLog.log(request, LogType.RECEIVE_MOVEMENT, ExchangeLogStatusTypeType.ISSUED, TypeRefType.MOVEMENT, JAXBMarshaller.marshallJaxBObjectToString(request), true);
            forwardToRules(RulesModuleRequestMapper.createSetMovementReportRequest(PluginTypeMapper.map(pluginType), rawMovement, username), message, service);
            log.info("[INFO] Finished forwarding received movement to rules module.");
        } else {
            log.debug("[ERROR] Validation error. Event sent to plugin {}", message);
        }
    } catch (ExchangeServiceException e) {
        log.error("[ERROR] Couldn't get the Service type for the received message : {} {}", message, e);
    } catch (ExchangeModelMarshallException e) {
        log.error("[ERROR] Couldn't map to SetMovementReportRequest when processing movement from plugin:{} {}", message, e);
    } catch (JMSException e) {
        log.error("[ERROR] Failed to get response queue:{} {}", message, e);
    } catch (RulesModelMapperException e) {
        log.error("[ERROR] Failed to build Rules momvent request:{} {}", message, e);
    } catch (ExchangeLogException e) {
        log.error("[ERROR] Failed to log momvent request : {} {}", message, e);
    }
}
Also used : ServiceResponseType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType) MovementBaseType(eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementBaseType) JMSException(javax.jms.JMSException) ProcessedMovementAck(eu.europa.ec.fisheries.schema.movement.module.v1.ProcessedMovementAck) PluginType(eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType) RulesModelMapperException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException) ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) RawMovementType(eu.europa.ec.fisheries.schema.rules.movement.v1.RawMovementType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) SetReportMovementType(eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType) AssetId(eu.europa.ec.fisheries.schema.rules.asset.v1.AssetId) TextMessage(javax.jms.TextMessage) SetMovementReportRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.SetMovementReportRequest)

Example 2 with ExchangeServiceException

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

the class ExchangeServiceBean method upsertSettings.

@Override
public ServiceResponseType upsertSettings(String serviceClassName, SettingListType settingListType, String username) throws ExchangeServiceException {
    LOG.info("Upsert settings in service layer: {} {} {}", serviceClassName, settingListType, username);
    try {
        ServiceResponseType updatedSettings = serviceRegistryModel.updatePluginSettings(serviceClassName, settingListType, username);
        sendAuditLogMessageForUpdateService(compressServiceClassName(serviceClassName), username);
        return updatedSettings;
    } catch (ExchangeModelException e) {
        throw new ExchangeServiceException(e.getMessage());
    }
}
Also used : 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 ExchangeServiceException

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

the class ExchangeServiceBean method unregisterService.

/**
 * {@inheritDoc}
 *
 * @param data
 * @throws ExchangeServiceException
 */
@Override
public ServiceResponseType unregisterService(ServiceType data, String username) throws ExchangeServiceException {
    LOG.info("Unregister service invoked in service layer: {} {}", data, username);
    try {
        ServiceResponseType serviceResponseType = serviceRegistryModel.unregisterService(data, username);
        sendAuditLogMessageForUnregisterService(compressServiceClassName(serviceResponseType.getServiceClassName()), username);
        return serviceResponseType;
    } catch (ExchangeModelException ex) {
        throw new ExchangeServiceException(ex.getMessage());
    }
}
Also used : 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 4 with ExchangeServiceException

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

the class ExchangeServiceBean method updateServiceStatus.

@Override
public ServiceResponseType updateServiceStatus(String serviceClassName, StatusType status, String username) throws ExchangeServiceException {
    LOG.info("Update service status invoked in service layer: {} {} {}", serviceClassName, status, username);
    try {
        ServiceResponseType updatedServiceStatus = serviceRegistryModel.updatePluginStatus(serviceClassName, status, username);
        sendAuditLogMessageForUpdateServiceStatus(serviceClassName, status, username);
        return updatedServiceStatus;
    } catch (ExchangeModelException e) {
        throw new ExchangeServiceException(e.getMessage());
    }
}
Also used : 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 5 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)

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 TextMessage (javax.jms.TextMessage)4 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.service.exception.InputArgumentException)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 SetReportMovementType (eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType)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