Search in sources :

Example 6 with ResponseMessageResultType

use of org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType in project open-smart-grid-platform by OSGP.

the class DeviceManagementService method handleRevokeKeyResponse.

public void handleRevokeKeyResponse(final String organisationIdentification, final String deviceIdentification, final String correlationUid, final String messageType, final ResponseMessageResultType deviceResult, final OsgpException exception) {
    LOGGER.info("MessageType: {}. Handle revoke key for device: {} for organisation: {}", messageType, deviceIdentification, organisationIdentification);
    ResponseMessageResultType result = ResponseMessageResultType.OK;
    OsgpException osgpException = exception;
    try {
        if (deviceResult == ResponseMessageResultType.NOT_OK || osgpException != null) {
            LOGGER.error("Device Response not ok.", osgpException);
            throw osgpException;
        }
        final Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification);
        if (device == null) {
            throw new PlatformException(String.format("Device not found: %s", deviceIdentification));
        }
        final Ssld ssld = this.ssldRepository.findByDeviceIdentification(deviceIdentification);
        ssld.setPublicKeyPresent(false);
        this.ssldRepository.save(ssld);
        LOGGER.info("publicKey has been revoked for device: {} for organisation: {}", deviceIdentification, organisationIdentification);
    } catch (final Exception e) {
        LOGGER.error("Unexpected Exception", e);
        result = ResponseMessageResultType.NOT_OK;
        osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while revoking key", e);
    }
    final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withCorrelationUid(correlationUid).withOrganisationIdentification(organisationIdentification).withDeviceIdentification(deviceIdentification).withResult(result).withOsgpException(osgpException).build();
    this.webServiceResponseMessageSender.send(responseMessage);
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) Device(org.opensmartgridplatform.domain.core.entities.Device) PlatformException(org.opensmartgridplatform.domain.core.exceptions.PlatformException) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) UnknownEntityException(org.opensmartgridplatform.domain.core.exceptions.UnknownEntityException) PlatformException(org.opensmartgridplatform.domain.core.exceptions.PlatformException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) Ssld(org.opensmartgridplatform.domain.core.entities.Ssld)

Example 7 with ResponseMessageResultType

use of org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType in project open-smart-grid-platform by OSGP.

the class DomainResponseMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) {
    LOGGER.debug("Processing public lighting response message");
    String correlationUid = null;
    String jmsType = null;
    String organisationIdentification = null;
    String deviceIdentification = null;
    NotificationType notificationType;
    ResponseMessageResultType resultType;
    String resultDescription;
    Serializable dataObject;
    try {
        correlationUid = message.getJMSCorrelationID();
        jmsType = message.getJMSType();
        organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
        deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
        resultType = ResponseMessageResultType.valueOf(message.getStringProperty(Constants.RESULT));
        resultDescription = message.getStringProperty(Constants.DESCRIPTION);
        notificationType = NotificationType.valueOf(jmsType);
        dataObject = message.getObject();
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        LOGGER.debug("correlationUid: {}", correlationUid);
        LOGGER.debug("messageType: {}", jmsType);
        LOGGER.debug("organisationIdentification: {}", organisationIdentification);
        LOGGER.debug("deviceIdentification: {}", deviceIdentification);
        return;
    }
    try {
        LOGGER.info("Calling application service function to handle response: {} with correlationUid: {}", jmsType, correlationUid);
        final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
        this.handleMessage(ids, jmsType, resultType, resultDescription, dataObject);
        this.notificationService.sendNotification(organisationIdentification, deviceIdentification, resultType.name(), correlationUid, resultDescription, notificationType);
    } catch (final RuntimeException e) {
        this.handleError(e, correlationUid, notificationType);
    }
}
Also used : Serializable(java.io.Serializable) NotificationType(org.opensmartgridplatform.adapter.ws.schema.publiclighting.notification.NotificationType) JMSException(javax.jms.JMSException) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) CorrelationIds(org.opensmartgridplatform.shared.infra.jms.CorrelationIds)

Example 8 with ResponseMessageResultType

use of org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType in project open-smart-grid-platform by OSGP.

the class ConfigurationService method handleGetConfigurationObjectResponse.

public void handleGetConfigurationObjectResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType deviceResult, final OsgpException exception, final GetConfigurationObjectResponseDto resultData) {
    log.info("handle GetConfigurationObject response for MessageType: {}", messageMetadata.getMessageType());
    final GetConfigurationObjectResponse response = this.configurationMapper.map(resultData, GetConfigurationObjectResponse.class);
    ResponseMessageResultType result = deviceResult;
    if (exception != null) {
        log.error(DEVICE_RESPONSE_NOT_OK_LOG_MSG, exception);
        result = ResponseMessageResultType.NOT_OK;
    }
    final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(result).withOsgpException(exception).withDataObject(response).build();
    this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
Also used : GetConfigurationObjectResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetConfigurationObjectResponse) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)

Example 9 with ResponseMessageResultType

use of org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType in project open-smart-grid-platform by OSGP.

the class ConfigurationService method handleSetPushSetupSmsResponse.

public void handleSetPushSetupSmsResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType deviceResult, final OsgpException exception) {
    log.info("handleSetPushSetupSmsResponse for MessageType: {}", messageMetadata.getMessageType());
    ResponseMessageResultType result = deviceResult;
    if (exception != null) {
        log.error("Set Push Setup Sms Response not ok. Unexpected Exception", exception);
        result = ResponseMessageResultType.NOT_OK;
    }
    final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(result).withOsgpException(exception).build();
    this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
Also used : ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)

Example 10 with ResponseMessageResultType

use of org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType in project open-smart-grid-platform by OSGP.

the class ConfigurationService method handleSetConfigurationObjectResponse.

public void handleSetConfigurationObjectResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType deviceResult, final OsgpException exception) {
    log.info("handle SetConfigurationObject response for MessageType: {}", messageMetadata.getMessageType());
    ResponseMessageResultType result = deviceResult;
    if (exception != null) {
        log.error(DEVICE_RESPONSE_NOT_OK_LOG_MSG, exception);
        result = ResponseMessageResultType.NOT_OK;
    }
    final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(result).withOsgpException(exception).build();
    this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
Also used : ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)

Aggregations

ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)102 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)78 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)52 JMSException (javax.jms.JMSException)39 CorrelationIds (org.opensmartgridplatform.shared.infra.jms.CorrelationIds)24 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)20 ProtocolResponseMessage (org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)17 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)15 Serializable (java.io.Serializable)12 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)12 Test (org.junit.jupiter.api.Test)6 DeviceStatusDto (org.opensmartgridplatform.dto.valueobjects.DeviceStatusDto)6 IOException (java.io.IOException)5 Ssld (org.opensmartgridplatform.domain.core.entities.Ssld)4 UnknownEntityException (org.opensmartgridplatform.domain.core.exceptions.UnknownEntityException)4 FirmwareVersion (org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion)4 GetStatusDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse)3 Device (org.opensmartgridplatform.domain.core.entities.Device)3 FirmwareVersionDto (org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto)3 Calendar (java.util.Calendar)2