Search in sources :

Example 61 with OsgpException

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

the class MonitoringEndpoint method getPQValuesPeriodicAsync.

@PayloadRoot(localPart = "GetPQValuesPeriodicAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public GetPQValuesPeriodicResponse getPQValuesPeriodicAsync(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetPQValuesPeriodicAsyncRequest request) throws OsgpException {
    LOGGER.info("Get PQ Values Periodic Response received from organisation: {} for correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
    GetPQValuesPeriodicResponse response = new GetPQValuesPeriodicResponse();
    try {
        final org.opensmartgridplatform.domain.da.valueobjects.GetPQValuesResponse dataResponse = this.service.dequeueGetPQValuesPeriodicResponse(request.getAsyncRequest().getCorrelationUid());
        if (dataResponse != null) {
            response = this.mapper.map(dataResponse, GetPQValuesPeriodicResponse.class);
            response.setResult(OsgpResultType.OK);
        } else {
            response.setResult(OsgpResultType.NOT_FOUND);
        }
    } catch (final ResponseNotFoundException e) {
        LOGGER.warn("ResponseNotFoundException for getPQValuesPeriodicAsync", e);
        response.setResult(OsgpResultType.NOT_FOUND);
    } catch (final Exception e) {
        this.handleException(LOGGER, e);
    }
    response.setDeviceIdentification(request.getAsyncRequest().getDeviceId());
    return response;
}
Also used : ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException) GetPQValuesPeriodicResponse(org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.GetPQValuesPeriodicResponse) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 62 with OsgpException

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

the class MonitoringEndpoint method getPQValues.

@PayloadRoot(localPart = "GetPQValuesRequest", namespace = NAMESPACE)
@ResponsePayload
public GetPQValuesAsyncResponse getPQValues(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetPQValuesRequest request) throws OsgpException {
    LOGGER.info("Get PQ Values Request received from organisation: {} for device: {}.", organisationIdentification, request.getDeviceIdentification());
    final GetPQValuesAsyncResponse response = new GetPQValuesAsyncResponse();
    try {
        final org.opensmartgridplatform.domain.da.valueobjects.GetPQValuesRequest getPQValue = this.mapper.map(request, org.opensmartgridplatform.domain.da.valueobjects.GetPQValuesRequest.class);
        final String correlationUid = this.service.enqueueGetPQValuesRequest(organisationIdentification, request.getDeviceIdentification(), getPQValue);
        final AsyncResponse asyncResponse = new AsyncResponse();
        asyncResponse.setCorrelationUid(correlationUid);
        asyncResponse.setDeviceId(request.getDeviceIdentification());
        response.setAsyncResponse(asyncResponse);
    } catch (final Exception e) {
        this.handleException(LOGGER, e);
    }
    return response;
}
Also used : GetPQValuesAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.GetPQValuesAsyncResponse) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.distributionautomation.common.AsyncResponse) GetPQValuesPeriodicAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.GetPQValuesPeriodicAsyncResponse) GetPQValuesAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.GetPQValuesAsyncResponse) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 63 with OsgpException

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

the class MonitoringEndpoint method getPQValuesAsync.

@PayloadRoot(localPart = "GetPQValuesAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public GetPQValuesResponse getPQValuesAsync(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetPQValuesAsyncRequest request) throws OsgpException {
    LOGGER.info("Get PQ Values Response received from organisation: {} for correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
    GetPQValuesResponse response = new GetPQValuesResponse();
    try {
        final org.opensmartgridplatform.domain.da.valueobjects.GetPQValuesResponse dataResponse = this.service.dequeueGetPQValuesResponse(request.getAsyncRequest().getCorrelationUid());
        if (dataResponse != null) {
            response = this.mapper.map(dataResponse, GetPQValuesResponse.class);
            response.setResult(OsgpResultType.OK);
        } else {
            response.setResult(OsgpResultType.NOT_FOUND);
        }
    } catch (final ResponseNotFoundException e) {
        LOGGER.warn("ResponseNotFoundException for getGetDataResponse", e);
        response.setResult(OsgpResultType.NOT_FOUND);
    } catch (final Exception e) {
        this.handleException(LOGGER, e);
    }
    response.setDeviceIdentification(request.getAsyncRequest().getDeviceId());
    return response;
}
Also used : ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException) GetPQValuesResponse(org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.GetPQValuesResponse) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 64 with OsgpException

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

the class AdHocManagementEndpoint method getGetDataResponse.

@PayloadRoot(localPart = "GetDataAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public GetDataResponse getGetDataResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetDataAsyncRequest request) throws OsgpException {
    LOGGER.info("Get Data Response received from organisation: {} for correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
    GetDataResponse response = new GetDataResponse();
    try {
        final org.opensmartgridplatform.domain.microgrids.valueobjects.GetDataResponse dataResponse = this.service.dequeueGetDataResponse(request.getAsyncRequest().getCorrelationUid());
        if (dataResponse != null) {
            response = this.mapper.map(dataResponse, GetDataResponse.class);
            response.setResult(OsgpResultType.OK);
        } else {
            response.setResult(OsgpResultType.NOT_FOUND);
        }
    } catch (final ResponseNotFoundException e) {
        LOGGER.warn("ResponseNotFoundException for getGetDataResponse", e);
        response.setResult(OsgpResultType.NOT_FOUND);
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException) GetDataResponse(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataResponse) ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 65 with OsgpException

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

the class AdHocManagementEndpoint method getSetDataResponse.

@PayloadRoot(localPart = "SetDataAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public SetDataResponse getSetDataResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetDataAsyncRequest request) throws OsgpException {
    LOGGER.info("Get Set Data Response received from organisation: {} with correlationUid: {}.", organisationIdentification, request.getAsyncRequest().getCorrelationUid());
    final SetDataResponse response = new SetDataResponse();
    try {
        final EmptyResponse setDataResponse = this.service.dequeueSetDataResponse(request.getAsyncRequest().getCorrelationUid());
        if (setDataResponse != null) {
            response.setResult(OsgpResultType.OK);
        } else {
            response.setResult(OsgpResultType.NOT_FOUND);
        }
    } catch (final ResponseNotFoundException e) {
        LOGGER.warn("ResponseNotFoundException for getSetDataResponse", e);
        response.setResult(OsgpResultType.NOT_FOUND);
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException) SetDataResponse(org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.SetDataResponse) EmptyResponse(org.opensmartgridplatform.domain.microgrids.valueobjects.EmptyResponse) ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) 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