Search in sources :

Example 21 with OwsServiceRequest

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

the class SwesDecoderv20 method parseDeleteSensor.

private OwsServiceRequest parseDeleteSensor(final DeleteSensorDocument xbDelSenDoc) throws DecodingException {
    final DeleteSensorRequest request = new DeleteSensorRequest();
    DeleteSensorType deleteSensor = xbDelSenDoc.getDeleteSensor();
    request.setService(deleteSensor.getService());
    request.setVersion(deleteSensor.getVersion());
    request.setProcedureIdentifier(deleteSensor.getProcedure());
    // extensions
    request.setExtensions(parseExtensibleRequest(deleteSensor));
    return request;
}
Also used : DeleteSensorRequest(org.n52.shetland.ogc.sos.request.DeleteSensorRequest) DeleteSensorType(net.opengis.swes.x20.DeleteSensorType)

Example 22 with OwsServiceRequest

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

the class SwesDecoderv20 method parseUpdateSensorDescription.

/**
 * parses the Xmlbeans UpdateSensorDescription document to a SOS request.
 *
 * @param xbUpSenDoc
 *            UpdateSensorDescription document
 * @return SOS UpdateSensor request
 *
 * @throws DecodingException
 *             * if an error occurs.
 */
private OwsServiceRequest parseUpdateSensorDescription(final UpdateSensorDescriptionDocument xbUpSenDoc) throws DecodingException {
    final UpdateSensorRequest request = new UpdateSensorRequest();
    final UpdateSensorDescriptionType xbUpdateSensor = xbUpSenDoc.getUpdateSensorDescription();
    request.setService(xbUpdateSensor.getService());
    request.setVersion(xbUpdateSensor.getVersion());
    request.setProcedureIdentifier(xbUpdateSensor.getProcedure());
    request.setProcedureDescriptionFormat(xbUpdateSensor.getProcedureDescriptionFormat());
    // extensions
    request.setExtensions(parseExtensibleRequest(xbUpdateSensor));
    for (final Description description : xbUpdateSensor.getDescriptionArray()) {
        SensorDescriptionType sensorDescription = description.getSensorDescription();
        try {
            // TODO exception if valid time is set
            final XmlObject xmlObject = XmlObject.Factory.parse(getNodeFromNodeList(sensorDescription.getData().getDomNode().getChildNodes()));
            Decoder<?, XmlObject> decoder = getDecoder(getDecoderKey(xmlObject));
            if (decoder == null) {
                throw new DecodingException(UpdateSensorDescriptionParams.procedureDescriptionFormat, "The requested procedureDescritpionFormat is not supported!");
            }
            final Object decodedObject = decoder.decode(xmlObject);
            SosProcedureDescription<?> sosProcedureDescription = null;
            if (decodedObject instanceof SosProcedureDescription) {
                sosProcedureDescription = (SosProcedureDescription) decodedObject;
            } else if (decodedObject instanceof AbstractFeature) {
                sosProcedureDescription = new SosProcedureDescription<>((AbstractFeature) decodedObject);
            }
            if (sosProcedureDescription != null) {
                if (sensorDescription.isSetValidTime()) {
                    sosProcedureDescription.setValidTime(getValidTime(sensorDescription.getValidTime()));
                }
            }
            request.addProcedureDescriptionString(sosProcedureDescription);
        } catch (final XmlException xmle) {
            throw new DecodingException("Error while parsing procedure description of UpdateSensor request!", xmle);
        }
    }
    return request;
}
Also used : UpdateSensorDescriptionType(net.opengis.swes.x20.UpdateSensorDescriptionType) UpdateSensorRequest(org.n52.shetland.ogc.sos.request.UpdateSensorRequest) SosProcedureDescription(org.n52.shetland.ogc.sos.SosProcedureDescription) Description(net.opengis.swes.x20.UpdateSensorDescriptionType.Description) XmlException(org.apache.xmlbeans.XmlException) SosProcedureDescription(org.n52.shetland.ogc.sos.SosProcedureDescription) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) OwsServiceCommunicationObject(org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject) XmlObject(org.apache.xmlbeans.XmlObject) SensorDescriptionType(net.opengis.swes.x20.SensorDescriptionType) UpdateSensorDescriptionType(net.opengis.swes.x20.UpdateSensorDescriptionType)

Example 23 with OwsServiceRequest

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

the class AbstractSoapDecoder method getSOAPBodyContent.

/**
 * Parses the SOAPBody content to a text representation
 *
 * @param message
 *            SOAP message
 *
 * @return SOAPBody content as text
 *
 * @throws DecodingException
 *             * if an error occurs.
 */
protected OwsServiceRequest getSOAPBodyContent(SOAPMessage message) throws DecodingException {
    try {
        Document bodyRequestDoc = message.getSOAPBody().extractContentAsDocument();
        String xmlString = W3cHelper.nodeToXmlString(bodyRequestDoc.getDocumentElement());
        return decodeXmlElement(XmlObject.Factory.parse(xmlString, getXmlOptions()));
    } catch (SOAPException | XmlException | IOException e) {
        throw new DecodingException("Error while parsing SOAPMessage body content!", e);
    }
}
Also used : XmlException(org.apache.xmlbeans.XmlException) SOAPException(javax.xml.soap.SOAPException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) IOException(java.io.IOException) Document(org.w3c.dom.Document)

Example 24 with OwsServiceRequest

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

the class BatchRequestDecoder method getDecoder.

private Decoder<OwsServiceRequest, JsonNode> getDecoder(JsonNode n) throws DecodingException {
    String service = n.path(JSONConstants.SERVICE).textValue();
    String version = n.path(JSONConstants.VERSION).textValue();
    String request = n.path(JSONConstants.REQUEST).textValue();
    OperationDecoderKey k = new OperationDecoderKey(service, version, request, MediaTypes.APPLICATION_JSON);
    Decoder<OwsServiceRequest, JsonNode> decoder = getDecoder(k);
    if (decoder == null) {
        // TODO other exception?
        throw new NoDecoderForKeyException(k);
    }
    return decoder;
}
Also used : NoDecoderForKeyException(org.n52.svalbard.decode.exception.NoDecoderForKeyException) JsonNode(com.fasterxml.jackson.databind.JsonNode) OwsServiceRequest(org.n52.shetland.ogc.ows.service.OwsServiceRequest) OperationDecoderKey(org.n52.svalbard.decode.OperationDecoderKey)

Example 25 with OwsServiceRequest

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

the class RequestResponseModifierKeyTypeTest method getModifiedRequest.

private OwsServiceRequest getModifiedRequest() {
    OwsServiceRequest request = new RequestImpl();
    request.setService(SERVICE).setVersion(VERSION);
    return request;
}
Also used : OwsServiceRequest(org.n52.shetland.ogc.ows.service.OwsServiceRequest)

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