Search in sources :

Example 1 with ResponseNotFoundException

use of org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException 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 2 with ResponseNotFoundException

use of org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException 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)

Example 3 with ResponseNotFoundException

use of org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException in project open-smart-grid-platform by OSGP.

the class MicrogridsService method dequeueSetDataResponse.

public EmptyResponse dequeueSetDataResponse(final String correlationUid) throws OsgpException {
    LOGGER.debug("dequeueSetDataRequest called with correlation uid {}", correlationUid);
    final ResponseData responseData = this.responseDataService.dequeue(correlationUid, ResponseMessage.class, ComponentType.WS_MICROGRIDS);
    final ResponseMessage response = (ResponseMessage) responseData.getMessageData();
    switch(response.getResult()) {
        case NOT_FOUND:
            throw new ResponseNotFoundException(ComponentType.WS_MICROGRIDS, "Response message not found.");
        case NOT_OK:
            if (response.getOsgpException() != null) {
                throw response.getOsgpException();
            }
            throw new TechnicalException(ComponentType.WS_MICROGRIDS, "Response message not ok.");
        case OK:
            return new EmptyResponse();
        default:
            // Should not get here
            throw new TechnicalException(ComponentType.WS_MICROGRIDS, "Response message contains invalid result.");
    }
}
Also used : ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) ResponseData(org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) EmptyResponse(org.opensmartgridplatform.domain.microgrids.valueobjects.EmptyResponse)

Example 4 with ResponseNotFoundException

use of org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException in project open-smart-grid-platform by OSGP.

the class MicrogridsService method dequeueGetDataResponse.

public GetDataResponse dequeueGetDataResponse(final String correlationUid) throws OsgpException {
    LOGGER.debug("dequeueGetDataRequest called with correlation uid {}", correlationUid);
    final ResponseData responseData = this.responseDataService.dequeue(correlationUid, ResponseMessage.class, ComponentType.WS_MICROGRIDS);
    final ResponseMessage response = (ResponseMessage) responseData.getMessageData();
    switch(response.getResult()) {
        case NOT_FOUND:
            throw new ResponseNotFoundException(ComponentType.WS_MICROGRIDS, "Response message not found.");
        case NOT_OK:
            if (response.getOsgpException() != null) {
                throw response.getOsgpException();
            }
            throw new TechnicalException(ComponentType.WS_MICROGRIDS, "Response message not ok.");
        case OK:
            return (GetDataResponse) response.getDataObject();
        default:
            // Should not get here
            throw new TechnicalException(ComponentType.WS_MICROGRIDS, "Response message contains invalid result.");
    }
}
Also used : ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) ResponseData(org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData) GetDataResponse(org.opensmartgridplatform.domain.microgrids.valueobjects.GetDataResponse) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage)

Aggregations

ResponseNotFoundException (org.opensmartgridplatform.adapter.ws.microgrids.application.exceptionhandling.ResponseNotFoundException)4 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)4 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)2 EmptyResponse (org.opensmartgridplatform.domain.microgrids.valueobjects.EmptyResponse)2 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)2 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)2 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)2 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)2 GetDataResponse (org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.GetDataResponse)1 SetDataResponse (org.opensmartgridplatform.adapter.ws.schema.microgrids.adhocmanagement.SetDataResponse)1 GetDataResponse (org.opensmartgridplatform.domain.microgrids.valueobjects.GetDataResponse)1