use of org.opensmartgridplatform.dto.valueobjects.ConfigurationDto in project open-smart-grid-platform by OSGP.
the class CommonGetConfigurationRequestMessageProcessor method handleGetConfigurationDeviceResponse.
private void handleGetConfigurationDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final DomainInformation domainInformation, final String messageType, final int retryCount, final boolean isScheduled) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException osgpException = null;
ConfigurationDto configuration = null;
try {
final GetConfigurationDeviceResponse response = (GetConfigurationDeviceResponse) deviceResponse;
configuration = response.getConfiguration();
} 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 MessageMetadata messageMetadata = MessageMetadata.newBuilder().withDeviceIdentification(deviceResponse.getDeviceIdentification()).withOrganisationIdentification(deviceResponse.getOrganisationIdentification()).withCorrelationUid(deviceResponse.getCorrelationUid()).withMessageType(messageType).withDomain(domainInformation.getDomain()).withDomainVersion(domainInformation.getDomainVersion()).withMessagePriority(deviceResponse.getMessagePriority()).withScheduled(isScheduled).withRetryCount(retryCount).build();
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata).result(result).osgpException(osgpException).dataObject(configuration).build();
responseMessageSender.send(responseMessage);
}
use of org.opensmartgridplatform.dto.valueobjects.ConfigurationDto in project open-smart-grid-platform by OSGP.
the class CommonGetConfigurationResponseMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing common get configuration response message");
String correlationUid = null;
String messageType = null;
int messagePriority = MessagePriorityEnum.DEFAULT.getPriority();
String organisationIdentification = null;
String deviceIdentification = null;
ResponseMessage responseMessage;
ResponseMessageResultType responseMessageResultType = null;
OsgpException osgpException = null;
Object dataObject;
try {
correlationUid = message.getJMSCorrelationID();
messageType = message.getJMSType();
messagePriority = message.getJMSPriority();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
responseMessage = (ResponseMessage) message.getObject();
responseMessageResultType = responseMessage.getResult();
osgpException = responseMessage.getOsgpException();
dataObject = responseMessage.getDataObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
LOGGER.debug("correlationUid: {}", correlationUid);
LOGGER.debug("messageType: {}", messageType);
LOGGER.debug("messagePriority: {}", messagePriority);
LOGGER.debug("organisationIdentification: {}", organisationIdentification);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("responseMessageResultType: {}", responseMessageResultType);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("osgpException", osgpException);
return;
}
try {
LOGGER.info("Calling application service function to handle response: {}", messageType);
final ConfigurationDto configurationDto = (ConfigurationDto) dataObject;
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
this.configurationManagementService.handleGetConfigurationResponse(configurationDto, ids, messageType, messagePriority, responseMessageResultType, osgpException);
} catch (final Exception e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType, messagePriority);
}
}
use of org.opensmartgridplatform.dto.valueobjects.ConfigurationDto in project open-smart-grid-platform by OSGP.
the class DomainCoreMapperTest method convertsConfigurationDtoToConfiguration.
@Test
void convertsConfigurationDtoToConfiguration() {
final ConfigurationDto source = this.aConfigurationDto();
final Configuration result = this.mapper.map(source, Configuration.class);
assertThat(result).usingRecursiveComparison().isEqualTo(this.toConfiguration(source));
}
use of org.opensmartgridplatform.dto.valueobjects.ConfigurationDto in project open-smart-grid-platform by OSGP.
the class OslpDeviceService method buildDeviceResponseGetConfiguration.
private DeviceResponse buildDeviceResponseGetConfiguration(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse) {
ConfigurationDto configuration = null;
final DeviceMessageStatus status;
if (oslpResponse.getPayloadMessage().hasGetConfigurationResponse()) {
final Oslp.GetConfigurationResponse getConfigurationResponse = oslpResponse.getPayloadMessage().getGetConfigurationResponse();
configuration = this.mapper.map(getConfigurationResponse, ConfigurationDto.class);
status = this.mapper.map(getConfigurationResponse.getStatus(), DeviceMessageStatus.class);
} else {
status = DeviceMessageStatus.FAILURE;
}
return new GetConfigurationDeviceResponse(deviceRequest, status, configuration);
}
use of org.opensmartgridplatform.dto.valueobjects.ConfigurationDto in project open-smart-grid-platform by OSGP.
the class CommonSetConfigurationRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) {
LOGGER.debug("Processing common set configuration message");
MessageMetadata messageMetadata;
ConfigurationDto configuration;
try {
messageMetadata = MessageMetadata.fromMessage(message);
configuration = (ConfigurationDto) message.getObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
return;
}
try {
this.printDomainInfo(messageMetadata.getMessageType(), messageMetadata.getDomain(), messageMetadata.getDomainVersion());
final SetConfigurationDeviceRequest deviceRequest = new SetConfigurationDeviceRequest(DeviceRequest.newBuilder().messageMetaData(messageMetadata), configuration);
this.deviceService.setConfiguration(deviceRequest);
} catch (final RuntimeException e) {
this.handleError(e, messageMetadata);
}
}
Aggregations