Search in sources :

Example 91 with OsgpException

use of org.opensmartgridplatform.shared.exceptionhandling.OsgpException in project open-smart-grid-platform by OSGP.

the class DeviceInstallationEndpoint method updateDevice.

@PayloadRoot(localPart = "UpdateDeviceRequest", namespace = DEVICE_INSTALLATION_NAMESPACE)
@ResponsePayload
public UpdateDeviceResponse updateDevice(@OrganisationIdentification final String organisationIdentification, @RequestPayload final UpdateDeviceRequest request) throws OsgpException {
    LOGGER.info("Updating device: {}.", request.getDeviceIdentification());
    try {
        final Ssld device = this.deviceInstallationMapper.map(request.getUpdatedDevice(), Ssld.class);
        this.deviceInstallationService.updateDevice(organisationIdentification, device);
    } catch (final ConstraintViolationException e) {
        throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_CORE, new ValidationException(e.getConstraintViolations()));
    } catch (final Exception e) {
        LOGGER.error(EXCEPTION_WHILE_UPDATING_DEVICE, e.getMessage(), request.getUpdatedDevice().getDeviceIdentification(), organisationIdentification, e);
        this.handleException(e);
    }
    try {
        this.notificationService.sendNotification(organisationIdentification, request.getDeviceIdentification(), null, null, null, NotificationType.DEVICE_UPDATED);
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    return new UpdateDeviceResponse();
}
Also used : ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) ConstraintViolationException(javax.validation.ConstraintViolationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) UpdateDeviceResponse(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.UpdateDeviceResponse) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ConstraintViolationException(javax.validation.ConstraintViolationException) Ssld(org.opensmartgridplatform.domain.core.entities.Ssld) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 92 with OsgpException

use of org.opensmartgridplatform.shared.exceptionhandling.OsgpException in project open-smart-grid-platform by OSGP.

the class DeviceInstallationEndpoint method startDeviceTest.

// === START DEVICE TEST ===
@PayloadRoot(localPart = "StartDeviceTestRequest", namespace = DEVICE_INSTALLATION_NAMESPACE)
@ResponsePayload
public StartDeviceTestAsyncResponse startDeviceTest(@OrganisationIdentification final String organisationIdentification, @RequestPayload final StartDeviceTestRequest request, @MessagePriority final String messagePriority) throws OsgpException {
    LOGGER.info("Start Device Test Request received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
    final StartDeviceTestAsyncResponse response = new StartDeviceTestAsyncResponse();
    try {
        final AsyncResponse asyncResponse = new AsyncResponse();
        final String correlationUid = this.deviceInstallationService.enqueueStartDeviceTestRequest(organisationIdentification, request.getDeviceIdentification(), MessagePriorityEnum.getMessagePriority(messagePriority));
        asyncResponse.setCorrelationUid(correlationUid);
        asyncResponse.setDeviceId(request.getDeviceIdentification());
        response.setAsyncResponse(asyncResponse);
    } catch (final ConstraintViolationException e) {
        throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_CORE, new ValidationException(e.getConstraintViolations()));
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) ConstraintViolationException(javax.validation.ConstraintViolationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse) StartDeviceTestAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.StartDeviceTestAsyncResponse) GetStatusAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.GetStatusAsyncResponse) StopDeviceTestAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.StopDeviceTestAsyncResponse) StartDeviceTestAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.StartDeviceTestAsyncResponse) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ConstraintViolationException(javax.validation.ConstraintViolationException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 93 with OsgpException

use of org.opensmartgridplatform.shared.exceptionhandling.OsgpException in project open-smart-grid-platform by OSGP.

the class DeviceInstallationEndpoint method getStartDeviceTestResponse.

@PayloadRoot(localPart = "StartDeviceTestAsyncRequest", namespace = DEVICE_INSTALLATION_NAMESPACE)
@ResponsePayload
public StartDeviceTestResponse getStartDeviceTestResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final StartDeviceTestAsyncRequest request) throws OsgpException {
    LOGGER.info("Get Start Device Test Response received from organisation: {} for device: {}.", organisationIdentification, request.getAsyncRequest().getDeviceId());
    final StartDeviceTestResponse response = new StartDeviceTestResponse();
    try {
        final ResponseMessage responseMessage = this.getResponseMessage(request.getAsyncRequest());
        if (responseMessage != null) {
            throwExceptionIfResultNotOk(responseMessage, "starting device test");
            response.setResult(OsgpResultType.fromValue(responseMessage.getResult().getValue()));
        }
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ConstraintViolationException(javax.validation.ConstraintViolationException) StartDeviceTestResponse(org.opensmartgridplatform.adapter.ws.schema.core.deviceinstallation.StartDeviceTestResponse) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 94 with OsgpException

use of org.opensmartgridplatform.shared.exceptionhandling.OsgpException in project open-smart-grid-platform by OSGP.

the class AdHocManagementEndpoint method getSetRebootResponse.

@PayloadRoot(localPart = "SetRebootAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public SetRebootResponse getSetRebootResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetRebootAsyncRequest request) throws OsgpException {
    LOGGER.info("Get Set Reboot Response received from organisation: {} with correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
    final SetRebootResponse response = new SetRebootResponse();
    try {
        final ResponseMessage responseMessage = this.getResponseMessage(request.getAsyncRequest());
        if (responseMessage != null) {
            throwExceptionIfResultNotOk(responseMessage, "rebooting");
            response.setResult(OsgpResultType.fromValue(responseMessage.getResult().getValue()));
        }
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : SetRebootResponse(org.opensmartgridplatform.adapter.ws.schema.core.adhocmanagement.SetRebootResponse) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 95 with OsgpException

use of org.opensmartgridplatform.shared.exceptionhandling.OsgpException in project open-smart-grid-platform by OSGP.

the class AdHocManagementEndpoint method setReboot.

// === SET REBOOT ===
@PayloadRoot(localPart = "SetRebootRequest", namespace = NAMESPACE)
@ResponsePayload
public SetRebootAsyncResponse setReboot(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetRebootRequest request, @MessagePriority final String messagePriority) throws OsgpException {
    LOGGER.info("Set Reboot received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
    final SetRebootAsyncResponse response = new SetRebootAsyncResponse();
    try {
        final String correlationUid = this.adHocManagementService.enqueueSetRebootRequest(organisationIdentification, request.getDeviceIdentification(), MessagePriorityEnum.getMessagePriority(messagePriority));
        final AsyncResponse asyncResponse = new AsyncResponse();
        asyncResponse.setCorrelationUid(correlationUid);
        asyncResponse.setDeviceId(request.getDeviceIdentification());
        response.setAsyncResponse(asyncResponse);
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : SetRebootAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.adhocmanagement.SetRebootAsyncResponse) SetRebootAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.adhocmanagement.SetRebootAsyncResponse) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)235 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)153 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)153 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)128 ConstraintViolationException (javax.validation.ConstraintViolationException)98 ValidationException (org.opensmartgridplatform.domain.core.exceptions.ValidationException)75 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)67 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)64 ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)54 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)51 JMSException (javax.jms.JMSException)40 IOException (java.io.IOException)30 GetKeysResponseData (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponseData)23 CorrelationIds (org.opensmartgridplatform.shared.infra.jms.CorrelationIds)18 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)17 AsyncResponse (org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncResponse)15 ProtocolResponseMessage (org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)15 ResponseNotFoundException (org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException)10 Device (org.opensmartgridplatform.domain.core.entities.Device)10 ArrayList (java.util.ArrayList)9