Search in sources :

Example 1 with ArgumentNullOrEmptyException

use of org.opensmartgridplatform.domain.core.exceptions.ArgumentNullOrEmptyException in project open-smart-grid-platform by OSGP.

the class DistributionAutomationService method processRequest.

private String processRequest(final String organisationIdentification, final String deviceIdentification, final Serializable request, final DeviceFunction deviceFunction, final MessageType messageType) throws OsgpException {
    final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
    final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
    final RtuDevice device = this.domainHelperService.findDevice(deviceIdentification);
    this.domainHelperService.isAllowed(organisation, device, deviceFunction);
    final DistributionAutomationRequestMessage message = new DistributionAutomationRequestMessage(messageType, correlationUid, organisationIdentification, deviceIdentification, request);
    try {
        this.requestMessageSender.send(message);
    } catch (final ArgumentNullOrEmptyException e) {
        throw new TechnicalException(ComponentType.WS_DISTRIBUTION_AUTOMATION, e);
    }
    return correlationUid;
}
Also used : TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) Organisation(org.opensmartgridplatform.domain.core.entities.Organisation) RtuDevice(org.opensmartgridplatform.domain.core.entities.RtuDevice) ArgumentNullOrEmptyException(org.opensmartgridplatform.domain.core.exceptions.ArgumentNullOrEmptyException) DistributionAutomationRequestMessage(org.opensmartgridplatform.adapter.ws.da.infra.jms.DistributionAutomationRequestMessage)

Example 2 with ArgumentNullOrEmptyException

use of org.opensmartgridplatform.domain.core.exceptions.ArgumentNullOrEmptyException in project open-smart-grid-platform by OSGP.

the class MicrogridsService method enqueueSetDataRequest.

public String enqueueSetDataRequest(final String organisationIdentification, final String deviceIdentification, final SetDataRequest setDataRequest) throws OsgpException {
    LOGGER.debug("enqueueSetDataRequest called with organisation {} and device {}", organisationIdentification, deviceIdentification);
    final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
    final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
    final RtuDevice device = this.domainHelperService.findDevice(deviceIdentification);
    this.domainHelperService.isAllowed(organisation, device, DeviceFunction.SET_DATA);
    final MicrogridsRequestMessage message = new MicrogridsRequestMessage(MessageType.SET_DATA, correlationUid, organisationIdentification, deviceIdentification, setDataRequest);
    try {
        this.requestMessageSender.send(message);
    } catch (final ArgumentNullOrEmptyException e) {
        throw new TechnicalException(ComponentType.WS_MICROGRIDS, e);
    }
    return correlationUid;
}
Also used : TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) Organisation(org.opensmartgridplatform.domain.core.entities.Organisation) RtuDevice(org.opensmartgridplatform.domain.core.entities.RtuDevice) ArgumentNullOrEmptyException(org.opensmartgridplatform.domain.core.exceptions.ArgumentNullOrEmptyException) MicrogridsRequestMessage(org.opensmartgridplatform.adapter.ws.microgrids.infra.jms.MicrogridsRequestMessage)

Example 3 with ArgumentNullOrEmptyException

use of org.opensmartgridplatform.domain.core.exceptions.ArgumentNullOrEmptyException in project open-smart-grid-platform by OSGP.

the class MicrogridsService method enqueueGetDataRequest.

public String enqueueGetDataRequest(@Identification final String organisationIdentification, @Identification final String deviceIdentification, @NotNull final GetDataRequest dataRequest) throws OsgpException {
    LOGGER.debug("enqueueGetDataRequest called with organisation {} and device {}", organisationIdentification, deviceIdentification);
    final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
    final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
    final RtuDevice device = this.domainHelperService.findDevice(deviceIdentification);
    this.domainHelperService.isAllowed(organisation, device, DeviceFunction.GET_DATA);
    final MicrogridsRequestMessage message = new MicrogridsRequestMessage(MessageType.GET_DATA, correlationUid, organisationIdentification, deviceIdentification, dataRequest);
    try {
        this.requestMessageSender.send(message);
    } catch (final ArgumentNullOrEmptyException e) {
        throw new TechnicalException(ComponentType.WS_MICROGRIDS, e);
    }
    return correlationUid;
}
Also used : TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) Organisation(org.opensmartgridplatform.domain.core.entities.Organisation) RtuDevice(org.opensmartgridplatform.domain.core.entities.RtuDevice) ArgumentNullOrEmptyException(org.opensmartgridplatform.domain.core.exceptions.ArgumentNullOrEmptyException) MicrogridsRequestMessage(org.opensmartgridplatform.adapter.ws.microgrids.infra.jms.MicrogridsRequestMessage)

Example 4 with ArgumentNullOrEmptyException

use of org.opensmartgridplatform.domain.core.exceptions.ArgumentNullOrEmptyException in project open-smart-grid-platform by OSGP.

the class DistributionAutomationService method enqueueAddRtuDeviceRequest.

public String enqueueAddRtuDeviceRequest(@Identification final String organisationIdentification, @Identification final String deviceIdentification, final AddRtuDeviceRequest addRtuDeviceRequest) throws OsgpException {
    LOGGER.debug("enqueueAddRtuDeviceRequest called with organisation {} and device {}", organisationIdentification, deviceIdentification);
    final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
    final DistributionAutomationRequestMessage message = new DistributionAutomationRequestMessage(MessageType.ADD_DEVICE, correlationUid, organisationIdentification, deviceIdentification, addRtuDeviceRequest);
    try {
        this.requestMessageSender.send(message);
    } catch (final ArgumentNullOrEmptyException e) {
        throw new TechnicalException(ComponentType.WS_DISTRIBUTION_AUTOMATION, e);
    }
    return correlationUid;
}
Also used : TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) ArgumentNullOrEmptyException(org.opensmartgridplatform.domain.core.exceptions.ArgumentNullOrEmptyException) DistributionAutomationRequestMessage(org.opensmartgridplatform.adapter.ws.da.infra.jms.DistributionAutomationRequestMessage)

Example 5 with ArgumentNullOrEmptyException

use of org.opensmartgridplatform.domain.core.exceptions.ArgumentNullOrEmptyException in project open-smart-grid-platform by OSGP.

the class DeviceManagementService method findDevices.

private Page<Device> findDevices(final String organisationIdentification, final DeviceFilter deviceFilter, final Organisation organisation, final PageRequest request) {
    final Page<Device> devices;
    try {
        if (!this.netManagementOrganisation.equals(organisationIdentification)) {
            // Municipality organization.
            if (deviceFilter == null) {
                final DeviceFilter df = new DeviceFilter();
                df.setOrganisationIdentification(organisationIdentification);
                df.setDeviceExternalManaged(DeviceExternalManagedFilterType.BOTH);
                df.setDeviceActivated(DeviceActivatedFilterType.BOTH);
                df.setDeviceInMaintenance(DeviceInMaintenanceFilterType.BOTH);
                df.setHasTechnicalInstallation(false);
                df.setExactMatch(false);
                devices = this.applyFilter(df, organisation, request);
            } else {
                deviceFilter.setOrganisationIdentification(organisationIdentification);
                devices = this.applyFilter(deviceFilter, organisation, request);
            }
        } else {
            // Net management organization.
            devices = this.applyFilter(deviceFilter, organisation, request);
        }
    } catch (final ArgumentNullOrEmptyException e) {
        /*
       * The implementation of applyFilter should check everything passed
       * on to DeviceSpecifications for not being empty, thus avoiding
       * ArgumentNullOrEmptyException. If something is missed (which
       * should not occur) pass it on as IllegalArgumentException to avoid
       * multiple checked exceptions being thrown.
       */
        throw new IllegalArgumentException("Null or empty input provided to DeviceSpecifications", e);
    }
    return devices;
}
Also used : DeviceFilter(org.opensmartgridplatform.domain.core.valueobjects.DeviceFilter) Device(org.opensmartgridplatform.domain.core.entities.Device) ArgumentNullOrEmptyException(org.opensmartgridplatform.domain.core.exceptions.ArgumentNullOrEmptyException)

Aggregations

ArgumentNullOrEmptyException (org.opensmartgridplatform.domain.core.exceptions.ArgumentNullOrEmptyException)5 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)4 Organisation (org.opensmartgridplatform.domain.core.entities.Organisation)3 RtuDevice (org.opensmartgridplatform.domain.core.entities.RtuDevice)3 DistributionAutomationRequestMessage (org.opensmartgridplatform.adapter.ws.da.infra.jms.DistributionAutomationRequestMessage)2 MicrogridsRequestMessage (org.opensmartgridplatform.adapter.ws.microgrids.infra.jms.MicrogridsRequestMessage)2 Device (org.opensmartgridplatform.domain.core.entities.Device)1 DeviceFilter (org.opensmartgridplatform.domain.core.valueobjects.DeviceFilter)1