use of org.opensmartgridplatform.shared.exceptionhandling.FunctionalException in project open-smart-grid-platform by OSGP.
the class RtuDeviceService method addProtocolInfo.
private void addProtocolInfo(final RtuDevice rtuDevice, final org.opensmartgridplatform.domain.core.entities.RtuDevice rtuDeviceEntity) throws FunctionalException {
final ProtocolInfo protocolInfo = this.protocolInfoRepository.findByProtocolAndProtocolVersion(rtuDevice.getProtocolName(), rtuDevice.getProtocolVersion());
if (protocolInfo == null) {
throw new FunctionalException(FunctionalExceptionType.UNKNOWN_PROTOCOL_NAME_OR_VERSION, ComponentType.DOMAIN_DISTRIBUTION_AUTOMATION);
}
rtuDeviceEntity.updateProtocol(protocolInfo);
}
use of org.opensmartgridplatform.shared.exceptionhandling.FunctionalException in project open-smart-grid-platform by OSGP.
the class AdHocManagementService method resumeSchedule.
// === RESUME SCHEDULE ===
public void resumeSchedule(final CorrelationIds ids, final Integer index, final boolean isImmediate, final String messageType, final int messagePriority) throws FunctionalException {
this.findOrganisation(ids.getOrganisationIdentification());
final Device device = this.findActiveDevice(ids.getDeviceIdentification());
final Ssld ssld = this.findSsldForDevice(device);
if (!ssld.getHasSchedule()) {
throw new FunctionalException(FunctionalExceptionType.UNSCHEDULED_DEVICE, ComponentType.DOMAIN_PUBLIC_LIGHTING, new ValidationException(String.format("Device %1$s does not have a schedule.", ids.getDeviceIdentification())));
}
final ResumeScheduleMessageDataContainerDto resumeScheduleMessageDataContainerDto = new ResumeScheduleMessageDataContainerDto(index, isImmediate);
this.osgpCoreRequestMessageSender.send(new RequestMessage(ids, resumeScheduleMessageDataContainerDto), messageType, messagePriority, device.getIpAddress());
}
use of org.opensmartgridplatform.shared.exceptionhandling.FunctionalException in project open-smart-grid-platform by OSGP.
the class AdHocManagementService method handleGetStatusResponse.
public void handleGetStatusResponse(final DeviceStatusDto deviceStatusDto, final CorrelationIds ids, final String messageType, final int messagePriority, final ResponseMessageResultType deviceResult, final OsgpException exception) {
LOGGER.info("handleResponse for MessageType: {}", messageType);
final GetStatusResponse response = new GetStatusResponse();
response.setOsgpException(exception);
response.setResult(deviceResult);
if (deviceResult == ResponseMessageResultType.NOT_OK || exception != null) {
LOGGER.error("Device Response not ok.", exception);
} else {
final DeviceStatus status = this.domainCoreMapper.map(deviceStatusDto, DeviceStatus.class);
try {
final Device dev = this.deviceDomainService.searchDevice(ids.getDeviceIdentification());
if (LightMeasurementDevice.LMD_TYPE.equals(dev.getDeviceType())) {
this.handleLmd(status, response);
} else {
this.handleSsld(ids.getDeviceIdentification(), status, DomainType.PUBLIC_LIGHTING, response);
}
} catch (final FunctionalException e) {
LOGGER.error("Caught FunctionalException", e);
}
}
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withIds(ids).withResult(response.getResult()).withOsgpException(response.getOsgpException()).withDataObject(response.getDeviceStatusMapped()).withMessagePriority(messagePriority).build();
this.webServiceResponseMessageSender.send(responseMessage);
}
use of org.opensmartgridplatform.shared.exceptionhandling.FunctionalException in project open-smart-grid-platform by OSGP.
the class SetEncryptionKeyExchangeOnGMeterDataConverter method convert.
@Override
public GMeterInfoDto convert(final SetEncryptionKeyExchangeOnGMeterRequestData value, final SmartMeter smartMeter) throws FunctionalException {
final SmartMeter gasDevice = this.domainHelperService.findSmartMeter(value.getDeviceIdentification());
final Device gatewayDevice = gasDevice.getGatewayDevice();
if (gatewayDevice == null) {
/*
* For now throw a FunctionalException, based on the same reasoning
* as with the channel a couple of lines up. As soon as we have
* scenario's with direct communication with gas meters this will
* have to be changed.
*/
throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.DOMAIN_SMART_METERING, new AssertionError("Meter for gas reads should have an energy meter as gateway device."));
}
return new GMeterInfoDto(gasDevice.getChannel(), gasDevice.getDeviceIdentification());
}
use of org.opensmartgridplatform.shared.exceptionhandling.FunctionalException in project open-smart-grid-platform by OSGP.
the class ActionMapperService method mapActionWithoutConverter.
private ActionDto mapActionWithoutConverter(final SmartMeter smartMeter, final ActionRequest action) throws FunctionalException {
final Class<? extends ActionRequestDto> clazz = CLASS_MAP.get(action.getClass());
final ConfigurableMapper mapper = CLASS_TO_MAPPER_MAP.get(action.getClass());
if (mapper != null) {
return this.mapActionWithMapper(smartMeter, action, clazz, mapper);
} else {
throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.DOMAIN_SMART_METERING, new AssertionError(String.format("No mapper defined for class: %s", clazz.getName())));
}
}
Aggregations