use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class DeviceRequestMessageProcessor method handleError.
protected void handleError(final IOException e, final String correlationUid, final String organisationIdentification, final String deviceIdentification, final String domain, final String domainVersion, final String messageType, final int messagePriority, final int retryCount) {
LOGGER.error("Error while processing message", e);
// Set the exception to a class known by all OSGP components
final TechnicalException ex = new TechnicalException(ComponentType.PROTOCOL_OSLP, UNEXPECTED_EXCEPTION);
final MessageMetadata messageMetadata = MessageMetadata.newBuilder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(messageType).withDomain(domain).withDomainVersion(domainVersion).withMessagePriority(messagePriority).withRetryCount(retryCount).build();
final ProtocolResponseMessage protocolResponseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata).result(ResponseMessageResultType.NOT_OK).osgpException(ex).build();
this.responseMessageSender.send(protocolResponseMessage);
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata 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);
}
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class CommonSwitchFirmwareRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) {
LOGGER.debug("Processing common switch firmware message");
MessageMetadata messageMetadata;
String version;
try {
messageMetadata = MessageMetadata.fromMessage(message);
version = (String) message.getObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
return;
}
this.printDomainInfo(messageMetadata.getMessageType(), messageMetadata.getDomain(), messageMetadata.getDomainVersion());
final SwitchFirmwareDeviceRequest deviceRequest = new SwitchFirmwareDeviceRequest(DeviceRequest.newBuilder().messageMetaData(messageMetadata), version);
this.deviceService.switchFirmware(deviceRequest);
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class AdminRevokeKeyRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) {
LOGGER.debug("Processing admin revoke key message");
MessageMetadata messageMetadata;
try {
messageMetadata = MessageMetadata.fromMessage(message);
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
return;
}
this.printDomainInfo(messageMetadata.getMessageType(), messageMetadata.getDomain(), messageMetadata.getDomainVersion());
this.deviceManagementService.revokeKey(messageMetadata, this.responseMessageSender);
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class DeviceManagementService method enqueueSetEventNotificationsRequest.
// === SET EVENT NOTIFICATIONS ===
@Transactional(value = "transactionManager")
public String enqueueSetEventNotificationsRequest(@Identification final String organisationIdentification, @Identification final String deviceIdentification, final List<EventNotificationType> eventNotifications, final int messagePriority) throws FunctionalException {
final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
final Device device = this.domainHelperService.findActiveDevice(deviceIdentification);
this.domainHelperService.isAllowed(organisation, device, DeviceFunction.SET_EVENT_NOTIFICATIONS);
this.domainHelperService.isInMaintenance(device);
LOGGER.debug("enqueueSetEventNotificationsRequest called with organisation {} and device {}", organisationIdentification, deviceIdentification);
final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
final EventNotificationMessageDataContainer eventNotificationMessageDataContainer = new EventNotificationMessageDataContainer(eventNotifications);
final MessageMetadata messageMetadata = new MessageMetadata.Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(MessageType.SET_EVENT_NOTIFICATIONS.name()).withMessagePriority(messagePriority).build();
final CommonRequestMessage message = new CommonRequestMessage.Builder().messageMetadata(messageMetadata).request(eventNotificationMessageDataContainer).build();
this.commonRequestMessageSender.send(message);
return correlationUid;
}
Aggregations