Search in sources :

Example 26 with OwsServiceRequest

use of org.n52.shetland.ogc.ows.service.OwsServiceRequest in project arctic-sea by 52North.

the class GenericServiceOperator method receiveRequest.

/**
 * {@inheritDoc}
 *
 * @throws OperationNotSupportedException if no matching
 *                                        {@link RequestOperator} could be
 *                                        found or if the operator returned
 *                                        a {@code null}-response.
 */
@Override
public OwsServiceResponse receiveRequest(OwsServiceRequest request) throws OwsExceptionReport {
    String operationName = request.getOperationName();
    RequestOperator operator = this.requestOperatorRepository.getRequestOperator(this.key, operationName);
    if (operator == null) {
        throw new OperationNotSupportedException(operationName);
    }
    OwsServiceResponse response = operator.receiveRequest(request);
    if (response == null) {
        throw new OperationNotSupportedException(operationName);
    }
    return response;
}
Also used : OperationNotSupportedException(org.n52.shetland.ogc.ows.exception.OperationNotSupportedException) RequestOperator(org.n52.iceland.request.operator.RequestOperator) OwsServiceResponse(org.n52.shetland.ogc.ows.service.OwsServiceResponse)

Example 27 with OwsServiceRequest

use of org.n52.shetland.ogc.ows.service.OwsServiceRequest in project arctic-sea by 52North.

the class GenericRequestOperator method receiveRequest.

@Override
public OwsServiceResponse receiveRequest(final OwsServiceRequest abstractRequest) throws OwsExceptionReport {
    this.eventBus.submit(new RequestEvent(abstractRequest));
    if (requestType.isAssignableFrom(abstractRequest.getClass())) {
        Q request = requestType.cast(abstractRequest);
        checkForModifierAndProcess(request);
        this.validator.validate(request);
        A response = receive(request);
        this.eventBus.submit(new ResponseEvent(response));
        checkForModifierAndProcess(request, response);
        return response;
    } else {
        throw new OperationNotSupportedException(abstractRequest.getOperationName());
    }
}
Also used : OperationNotSupportedException(org.n52.shetland.ogc.ows.exception.OperationNotSupportedException) RequestEvent(org.n52.iceland.event.events.RequestEvent) ResponseEvent(org.n52.iceland.event.events.ResponseEvent)

Example 28 with OwsServiceRequest

use of org.n52.shetland.ogc.ows.service.OwsServiceRequest in project arctic-sea by 52North.

the class GenericRequestOperator method checkForModifierAndProcess.

private void checkForModifierAndProcess(OwsServiceRequest request) throws OwsExceptionReport {
    if (!this.modifierRepository.hasRequestResponseModifier(request)) {
        return;
    }
    List<RequestResponseModifier> splitter = new LinkedList<>();
    List<RequestResponseModifier> remover = new LinkedList<>();
    List<RequestResponseModifier> defaultModifier = new LinkedList<>();
    this.modifierRepository.getRequestResponseModifier(request).stream().forEach(modifier -> {
        if (modifier.getFacilitator().isSplitter()) {
            splitter.add(modifier);
        } else if (modifier.getFacilitator().isAdderRemover()) {
            remover.add(modifier);
        } else {
            defaultModifier.add(modifier);
        }
    });
    // execute adder/remover
    for (RequestResponseModifier modifier : remover) {
        modifier.modifyRequest(request);
    }
    // execute default
    for (RequestResponseModifier modifier : defaultModifier) {
        modifier.modifyRequest(request);
    }
    // execute splitter
    for (RequestResponseModifier modifier : splitter) {
        modifier.modifyRequest(request);
    }
}
Also used : RequestResponseModifier(org.n52.iceland.convert.RequestResponseModifier) LinkedList(java.util.LinkedList)

Example 29 with OwsServiceRequest

use of org.n52.shetland.ogc.ows.service.OwsServiceRequest in project arctic-sea by 52North.

the class EXIBinding method parseRequest.

/**
 * Parse and decode the incoming EXI encoded {@link InputStream}
 *
 * @param request
 *            {@link HttpServletRequest} with EXI encoded
 *            {@link InputStream}
 * @return {@link OwsServiceRequest} from EXI encoded {@link InputStream}
 * @throws OwsExceptionReport
 *             If an error occurs during parsing
 */
protected OwsServiceRequest parseRequest(HttpServletRequest request) throws OwsExceptionReport {
    XmlObject doc = decode(request);
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("EXI-REQUEST: {}", doc.xmlText());
    }
    Decoder<OwsServiceRequest, XmlObject> decoder = getDecoder(CodingHelper.getDecoderKey(doc));
    try {
        return decoder.decode(doc).setRequestContext(getRequestContext(request));
    } catch (OwsDecodingException ex) {
        throw ex.getCause();
    } catch (DecodingException ex) {
        throw new InvalidParameterValueException().withMessage(ex.getMessage()).causedBy(ex).at(ex.getLocation().orElse(null));
    }
}
Also used : OwsDecodingException(org.n52.iceland.coding.decode.OwsDecodingException) InvalidParameterValueException(org.n52.shetland.ogc.ows.exception.InvalidParameterValueException) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) OwsDecodingException(org.n52.iceland.coding.decode.OwsDecodingException) OwsServiceRequest(org.n52.shetland.ogc.ows.service.OwsServiceRequest)

Example 30 with OwsServiceRequest

use of org.n52.shetland.ogc.ows.service.OwsServiceRequest in project arctic-sea by 52North.

the class JSONBinding method doPostOperation.

@Override
public void doPostOperation(HttpServletRequest req, HttpServletResponse res) throws HTTPException, IOException {
    OwsServiceRequest request = null;
    try {
        request = parseRequest(req);
        checkServiceOperatorKeyTypes(request);
        OwsServiceResponse response = getServiceOperator(request).receiveRequest(request);
        writeResponse(req, res, response);
    } catch (OwsExceptionReport oer) {
        oer.setVersion(request != null ? request.getVersion() : null);
        LOG.warn("Unexpected error", oer);
        writeOwsExceptionReport(req, res, oer);
    }
}
Also used : OwsServiceRequest(org.n52.shetland.ogc.ows.service.OwsServiceRequest) OwsServiceResponse(org.n52.shetland.ogc.ows.service.OwsServiceResponse) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport)

Aggregations

OwsServiceRequest (org.n52.shetland.ogc.ows.service.OwsServiceRequest)12 DecodingException (org.n52.svalbard.decode.exception.DecodingException)10 XmlObject (org.apache.xmlbeans.XmlObject)7 OwsServiceResponse (org.n52.shetland.ogc.ows.service.OwsServiceResponse)6 XmlException (org.apache.xmlbeans.XmlException)5 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)5 GetCapabilitiesRequest (org.n52.shetland.ogc.ows.service.GetCapabilitiesRequest)4 OwsServiceCommunicationObject (org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject)4 IOException (java.io.IOException)3 OwsDecodingException (org.n52.iceland.coding.decode.OwsDecodingException)3 InvalidServiceParameterException (org.n52.iceland.exception.ows.concrete.InvalidServiceParameterException)3 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)3 OperationDecoderKey (org.n52.svalbard.decode.OperationDecoderKey)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 LinkedList (java.util.LinkedList)2 Set (java.util.Set)2 GetFeatureOfInterest (net.opengis.sos.x10.GetFeatureOfInterestDocument.GetFeatureOfInterest)2 GetResultTemplateType (net.opengis.sos.x20.GetResultTemplateType)2 Test (org.junit.Test)2 VersionNotSupportedException (org.n52.iceland.exception.ows.concrete.VersionNotSupportedException)2