use of com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata in project Protocol-Adapter-OSLP by OSGP.
the class DeviceManagementService method sendResponseMessage.
private void sendResponseMessage(final String domain, final String domainVersion, final String messageType, final String correlationUid, final String organisationIdentification, final String deviceIdentification, final ResponseMessageResultType result, final OsgpException osgpException, final DeviceResponseMessageSender responseMessageSender) {
final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceIdentification, organisationIdentification, correlationUid, messageType, MessagePriorityEnum.DEFAULT.getPriority());
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(osgpException).build();
responseMessageSender.send(responseMessage);
}
use of com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata in project Protocol-Adapter-OSLP by OSGP.
the class OslpSigningService method handleError.
/**
* Handle an error from the signing server.
*/
public void handleError(final String deviceIdentification, final ResponseMessage responseMessage) {
final UnsignedOslpEnvelopeDto unsignedOslpEnvelopeDto = (UnsignedOslpEnvelopeDto) responseMessage.getDataObject();
final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceIdentification, unsignedOslpEnvelopeDto.getOrganisationIdentification(), unsignedOslpEnvelopeDto.getCorrelationUid(), unsignedOslpEnvelopeDto.getMessageType(), MessagePriorityEnum.DEFAULT.getPriority());
final ProtocolResponseMessage protocolResponseMessage = ProtocolResponseMessage.newBuilder().domain(unsignedOslpEnvelopeDto.getDomain()).domainVersion(unsignedOslpEnvelopeDto.getDomainVersion()).deviceMessageMetadata(deviceMessageMetadata).result(responseMessage.getResult()).osgpException(responseMessage.getOsgpException()).scheduled(unsignedOslpEnvelopeDto.isScheduled()).build();
this.deviceResponseMessageSender.send(protocolResponseMessage);
}
use of com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata in project Protocol-Adapter-OSLP by OSGP.
the class DeviceRequestMessageListener method sendException.
private void sendException(final ObjectMessage objectMessage, final Exception exception, final String errorMessage) {
try {
final String domain = objectMessage.getStringProperty(Constants.DOMAIN);
final String domainVersion = objectMessage.getStringProperty(Constants.DOMAIN_VERSION);
final ResponseMessageResultType result = ResponseMessageResultType.NOT_OK;
final OsgpException osgpException = new OsgpException(ComponentType.PROTOCOL_OSLP, errorMessage, exception);
final Serializable dataObject = objectMessage.getObject();
final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(objectMessage);
final ProtocolResponseMessage protocolResponseMessage = new ProtocolResponseMessage.Builder().deviceMessageMetadata(deviceMessageMetadata).domain(domain).domainVersion(domainVersion).result(result).osgpException(osgpException).dataObject(dataObject).scheduled(false).build();
this.deviceResponseMessageSender.send(protocolResponseMessage);
} catch (final Exception e) {
LOGGER.error("Unexpected error during sendException(ObjectMessage, Exception)", e);
}
}
use of com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata in project Protocol-Adapter-OSLP by OSGP.
the class DeviceRequestMessageProcessor method handleUnableToConnectDeviceResponse.
public void handleUnableToConnectDeviceResponse(final DeviceResponse deviceResponse, final Throwable t, final Serializable messageData, final DeviceResponseMessageSender responseMessageSender, final DeviceResponse deviceResponse2, final String domain, final String domainVersion, final String messageType, final boolean isScheduled, final int retryCount) {
final ResponseMessageResultType result = ResponseMessageResultType.NOT_OK;
final OsgpException ex = new TechnicalException(ComponentType.PROTOCOL_OSLP, StringUtils.isBlank(t.getMessage()) ? UNEXPECTED_EXCEPTION : t.getMessage(), t);
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(ex).dataObject(messageData).scheduled(isScheduled).retryCount(retryCount).build();
this.responseMessageSender.send(responseMessage);
}
use of com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata in project Protocol-Adapter-OSLP by OSGP.
the class DeviceRequestMessageProcessor method handleScheduledEmptyDeviceResponse.
protected void handleScheduledEmptyDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final boolean isScheduled, final int retryCount) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
TechnicalException ex = null;
try {
final EmptyDeviceResponse response = (EmptyDeviceResponse) deviceResponse;
this.deviceResponseService.handleDeviceMessageStatus(response.getStatus());
} catch (final TechnicalException e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
ex = 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(ex).scheduled(isScheduled).retryCount(retryCount).build();
responseMessageSender.send(responseMessage);
}
Aggregations