Search in sources :

Example 1 with BundleAsyncResponse

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.BundleAsyncResponse in project open-smart-grid-platform by OSGP.

the class SmartMeteringBundleEndpoint method bundleRequest.

@PayloadRoot(localPart = "BundleRequest", namespace = NAMESPACE)
@ResponsePayload
public BundleAsyncResponse bundleRequest(@ResponseUrl final String responseUrl, @MessageMetadata final org.opensmartgridplatform.shared.infra.jms.MessageMetadata messageMetadata, @RequestPayload final BundleRequest request) throws OsgpException {
    final String organisationIdentification = messageMetadata.getOrganisationIdentification();
    final String deviceIdentification = request.getDeviceIdentification();
    log.info("Incoming BundleRequest with responseUrl {} and {} actions. [deviceId={} | organisationId={}]", responseUrl, request.getActions().getActionList().size(), deviceIdentification, organisationIdentification);
    BundleAsyncResponse response = null;
    try {
        response = new BundleAsyncResponse();
        final List<ActionRequest> actionRequestList = this.actionMapperService.mapAllActions(request.getActions().getActionList());
        final String correlationUid = this.bundleService.enqueueBundleRequest(messageMetadata.builder().withDeviceIdentification(deviceIdentification).withMessageType(MessageType.HANDLE_BUNDLED_ACTIONS.name()).build(), actionRequestList);
        log.info("BundleRequest placed on queue [correlationId={} | deviceId={} | organisationId={}]", correlationUid, deviceIdentification, organisationIdentification);
        response.setCorrelationUid(correlationUid);
        response.setDeviceIdentification(request.getDeviceIdentification());
        this.saveResponseUrlIfNeeded(correlationUid, responseUrl);
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : ActionRequest(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActionRequest) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) BundleAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.BundleAsyncResponse) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 2 with BundleAsyncResponse

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.BundleAsyncResponse in project open-smart-grid-platform by OSGP.

the class BundleSteps method theBundleRequestIsReceived.

@When("^the bundle request is received$")
public void theBundleRequestIsReceived() throws Throwable {
    final BundleRequest request = (BundleRequest) ScenarioContext.current().get(PlatformSmartmeteringKeys.BUNDLE_REQUEST);
    final BundleAsyncResponse asyncResponse = this.client.sendBundleRequest(request);
    assertThat(asyncResponse).isNotNull();
    ScenarioContextHelper.saveAsyncResponse(asyncResponse);
}
Also used : BundleRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.BundleRequest) BundleAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.BundleAsyncResponse) When(io.cucumber.java.en.When)

Example 3 with BundleAsyncResponse

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.BundleAsyncResponse in project open-smart-grid-platform by OSGP.

the class BundleSteps method theBundleRequestIsReceivedWithHeaders.

@When("^the bundle request is received with headers$")
public void theBundleRequestIsReceivedWithHeaders(final Map<String, String> settings) throws Throwable {
    final BundleRequest request = (BundleRequest) ScenarioContext.current().get(PlatformSmartmeteringKeys.BUNDLE_REQUEST);
    /*
     * Scenarios containing this step may include a data table with two columns. The first column
     * should have the local part of the name of a SOAP header element and the second column should
     * have the text value for the named SOAP header element.
     *
     * These headers can be picked up by classes like those in osgp-adapter-ws-shared package
     * org.opensmartgridplatform.adapter.ws.endpointinterceptors, for instance the MessageMetadata
     * handling SoapHeaderMessageMetadataInterceptor or configurations of the more generic
     * SoapHeaderInterceptor.
     */
    final BundleAsyncResponse asyncResponse = this.client.sendBundleRequest(request, this.additionalSoapHeaders(settings));
    assertThat(asyncResponse).isNotNull();
    ScenarioContextHelper.saveAsyncResponse(asyncResponse);
}
Also used : BundleRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.BundleRequest) BundleAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.BundleAsyncResponse) When(io.cucumber.java.en.When)

Aggregations

BundleAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.BundleAsyncResponse)3 When (io.cucumber.java.en.When)2 BundleRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.BundleRequest)2 ActionRequest (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ActionRequest)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1