use of com.alliander.osgp.shared.infra.jms.ResponseMessageResultType in project Protocol-Adapter-OSLP by OSGP.
the class SigningServerResponsesMessageListener method onMessage.
@Override
public void onMessage(final Message message) {
try {
LOGGER.info("Received message of type: {}", message.getJMSType());
final ObjectMessage objectMessage = (ObjectMessage) message;
final String messageType = objectMessage.getJMSType();
final String correlationId = objectMessage.getJMSCorrelationID();
final String deviceIdentification = objectMessage.getStringProperty(Constants.DEVICE_IDENTIFICATION);
final ResponseMessage responseMessage = (ResponseMessage) objectMessage.getObject();
final ResponseMessageResultType result = responseMessage == null ? null : responseMessage.getResult();
// Check the result.
if (result.equals(ResponseMessageResultType.NOT_OK)) {
LOGGER.error("OslpEnvelope was not signed by signing-server. Unable to send request to device: {}", deviceIdentification);
this.oslpSigningService.handleError(deviceIdentification, responseMessage);
return;
}
LOGGER.info("messageType: {}, deviceIdentification: {}, result: {}, correlationId: {}", messageType, deviceIdentification, result, correlationId);
// Get the DTO object containing signed OslpEnvelope.
final SignedOslpEnvelopeDto signedOslpEnvelopeDto = (SignedOslpEnvelopeDto) responseMessage.getDataObject();
this.oslpSigningService.handleSignedOslpEnvelope(signedOslpEnvelopeDto, deviceIdentification);
} catch (final JMSException ex) {
LOGGER.error("Exception: {} ", ex.getMessage(), ex);
}
}
use of com.alliander.osgp.shared.infra.jms.ResponseMessageResultType in project Protocol-Adapter-OSLP by OSGP.
the class CommonGetStatusRequestMessageProcessor method handleGetStatusDeviceResponse.
private void handleGetStatusDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException osgpException = null;
DeviceStatusDto status = null;
try {
final GetStatusDeviceResponse response = (GetStatusDeviceResponse) deviceResponse;
status = response.getDeviceStatus();
} catch (final Exception e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while getting device status", e);
}
final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, MessagePriorityEnum.DEFAULT.getPriority());
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(osgpException).dataObject(status).retryCount(retryCount).build();
responseMessageSender.send(responseMessage);
}
use of com.alliander.osgp.shared.infra.jms.ResponseMessageResultType in project Protocol-Adapter-OSLP by OSGP.
the class PublicLightingGetStatusRequestMessageProcessor method handleGetStatusDeviceResponse.
private void handleGetStatusDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException osgpException = null;
DeviceStatusDto status = null;
try {
final GetStatusDeviceResponse response = (GetStatusDeviceResponse) deviceResponse;
status = response.getDeviceStatus();
} catch (final Exception e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while getting device status", e);
}
final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, MessagePriorityEnum.DEFAULT.getPriority());
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(osgpException).dataObject(status).retryCount(retryCount).build();
responseMessageSender.send(responseMessage);
}
use of com.alliander.osgp.shared.infra.jms.ResponseMessageResultType in project Protocol-Adapter-OSLP by OSGP.
the class TariffSwitchingGetStatusRequestMessageProcessor method handleGetStatusDeviceResponse.
private void handleGetStatusDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException osgpException = null;
DeviceStatusDto status = null;
try {
final GetStatusDeviceResponse response = (GetStatusDeviceResponse) deviceResponse;
status = response.getDeviceStatus();
} catch (final Exception e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while getting device status", e);
}
final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, MessagePriorityEnum.DEFAULT.getPriority());
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(osgpException).dataObject(status).retryCount(retryCount).build();
responseMessageSender.send(responseMessage);
}
use of com.alliander.osgp.shared.infra.jms.ResponseMessageResultType in project Protocol-Adapter-IEC61850 by OSGP.
the class MicrogridsGetDataRequestMessageProcessor method handleGetDataDeviceResponse.
private void handleGetDataDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException osgpException = null;
GetDataResponseDto dataResponse = null;
try {
final GetDataDeviceResponse response = (GetDataDeviceResponse) deviceResponse;
dataResponse = response.getDataResponse();
} catch (final Exception e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
osgpException = new TechnicalException(ComponentType.PROTOCOL_IEC61850, "Unexpected exception while retrieving response message", e);
}
final DeviceMessageMetadata deviceMessageMetaData = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, 0);
final ProtocolResponseMessage responseMessage = new ProtocolResponseMessage.Builder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetaData).result(result).osgpException(osgpException).dataObject(dataResponse).retryCount(retryCount).build();
responseMessageSender.send(responseMessage);
}
Aggregations