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);
}
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);
}
}
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());
}
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());
}
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());
}
Aggregations