use of org.opensmartgridplatform.shared.exceptionhandling.OsgpException in project open-smart-grid-platform by OSGP.
the class AdHocManagementEndpoint method getData.
// === GET DATA ===
@PayloadRoot(localPart = "GetDataRequest", namespace = NAMESPACE)
@ResponsePayload
public GetDataAsyncResponse getData(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetDataRequest request) throws OsgpException {
LOGGER.info("Get Data Request received from organisation: {} for device: {}.", organisationIdentification, request.getDeviceIdentification());
final GetDataAsyncResponse response = new GetDataAsyncResponse();
try {
final org.opensmartgridplatform.domain.microgrids.valueobjects.GetDataRequest dataRequest = this.mapper.map(request, org.opensmartgridplatform.domain.microgrids.valueobjects.GetDataRequest.class);
final String correlationUid = this.service.enqueueGetDataRequest(organisationIdentification, request.getDeviceIdentification(), dataRequest);
final AsyncResponse asyncResponse = new AsyncResponse();
asyncResponse.setCorrelationUid(correlationUid);
asyncResponse.setDeviceId(request.getDeviceIdentification());
response.setAsyncResponse(asyncResponse);
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
use of org.opensmartgridplatform.shared.exceptionhandling.OsgpException in project open-smart-grid-platform by OSGP.
the class AdHocManagementEndpoint method getDeviceModelResponse.
@PayloadRoot(localPart = "GetDeviceModelAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public GetDeviceModelResponse getDeviceModelResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetDeviceModelAsyncRequest request) throws OsgpException {
LOGGER.info("Get Device Model Response received from organisation: {} for correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
GetDeviceModelResponse response = new GetDeviceModelResponse();
try {
final org.opensmartgridplatform.domain.da.valueobjects.GetDeviceModelResponse dataResponse = this.service.dequeueGetDeviceModelResponse(request.getAsyncRequest().getCorrelationUid());
if (dataResponse != null) {
response = this.mapper.map(dataResponse, GetDeviceModelResponse.class);
response.setResult(OsgpResultType.OK);
} else {
response.setResult(OsgpResultType.NOT_FOUND);
}
} catch (final ResponseNotFoundException e) {
LOGGER.warn("ResponseNotFoundException for getDeviceModel", e);
response.setResult(OsgpResultType.NOT_FOUND);
} catch (final Exception e) {
this.handleException(LOGGER, e);
}
response.setDeviceIdentification(request.getAsyncRequest().getDeviceId());
return response;
}
use of org.opensmartgridplatform.shared.exceptionhandling.OsgpException in project open-smart-grid-platform by OSGP.
the class SessionProviderKpn method getIpAddress.
@Override
public String getIpAddress(final String iccId) throws OsgpException {
GetSessionInfoResponse response;
try {
response = this.jasperWirelessTerminalClient.getSession(iccId);
} catch (final SoapFaultClientException e) {
final String errorMessage = String.format("iccId %s is probably not supported in this session provider", iccId);
LOGGER.error(errorMessage, e);
throw new FunctionalException(FunctionalExceptionType.INVALID_ICCID, ComponentType.PROTOCOL_DLMS, new OsgpException(ComponentType.PROTOCOL_DLMS, e.getMessage()));
}
final SessionInfoType sessionInfoType = this.getSessionInfo(response);
if (sessionInfoType == null) {
return null;
}
return sessionInfoType.getIpAddress();
}
use of org.opensmartgridplatform.shared.exceptionhandling.OsgpException in project open-smart-grid-platform by OSGP.
the class GetFirmwareFileResponseMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Processing {} response message", this.messageType.name());
}
// Get metadata from message and update message type to update
// firmware
final MessageMetadata messageMetadata = new MessageMetadata.Builder(MessageMetadata.fromMessage(message)).withMessageType(MessageType.UPDATE_FIRMWARE.name()).build();
final Serializable messageObject = message.getObject();
final ThrowingConsumer<DlmsConnectionManager> taskForConnectionManager = conn -> this.processMessageTasks(messageObject, messageMetadata, conn);
try {
this.createAndHandleConnectionForDevice(this.domainHelperService.findDlmsDevice(messageMetadata), messageMetadata, taskForConnectionManager);
} catch (final OsgpException e) {
LOGGER.error("Something went wrong with the DlmsConnection", e);
}
}
use of org.opensmartgridplatform.shared.exceptionhandling.OsgpException in project open-smart-grid-platform by OSGP.
the class GetFirmwareFileResponseMessageProcessor method processMessageTasks.
@SuppressWarnings(// SilentException cannot be caught since it does not extend Exception.
"squid:S1193")
void processMessageTasks(final Serializable messageObject, final MessageMetadata messageMetadata, final DlmsConnectionManager conn) throws OsgpException {
try {
final DlmsDevice device = this.domainHelperService.findDlmsDevice(messageMetadata);
LOGGER.info("{} called for device: {} for organisation: {}", messageMetadata.getMessageType(), messageMetadata.getDeviceIdentification(), messageMetadata.getOrganisationIdentification());
final Serializable response;
response = this.handleMessage(conn, device, messageObject);
// Send response
this.sendResponseMessage(messageMetadata, ResponseMessageResultType.OK, null, this.responseMessageSender, response);
} catch (final Exception exception) {
// Return original request + exception
if (!(exception instanceof SilentException)) {
LOGGER.error("Unexpected exception during {}", this.messageType.name(), exception);
}
this.sendResponseMessage(messageMetadata, ResponseMessageResultType.NOT_OK, exception, this.responseMessageSender, this.createUpdateFirmwareRequestDto(messageObject));
} finally {
final DlmsDevice device = this.domainHelperService.findDlmsDevice(messageMetadata);
this.doConnectionPostProcessing(device, conn, messageMetadata);
}
}
Aggregations