Search in sources :

Example 6 with UnsupportedDecoderXmlInputException

use of org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException in project arctic-sea by 52North.

the class SwesExtensionDecoderv20 method decode.

@Override
public SwesExtension<?> decode(XmlObject xmlObject) throws DecodingException, UnsupportedDecoderInputException {
    if (isSwesExtension(xmlObject)) {
        XmlObject[] children = xmlObject.selectPath("./*");
        if (children.length == 1) {
            Object xmlObj = decodeXmlElement(children[0]);
            if (xmlObj instanceof SweAbstractDataComponent) {
                SwesExtension<SweAbstractDataComponent> extension = new SwesExtension<>();
                extension.setValue((SweAbstractDataComponent) xmlObj);
                return extension;
            }
        }
    }
    throw new UnsupportedDecoderXmlInputException(this, xmlObject);
}
Also used : SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) XmlObject(org.apache.xmlbeans.XmlObject) XmlObject(org.apache.xmlbeans.XmlObject) UnsupportedDecoderXmlInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException) SwesExtension(org.n52.shetland.ogc.swes.SwesExtension)

Example 7 with UnsupportedDecoderXmlInputException

use of org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException in project arctic-sea by 52North.

the class SosDecoderv100 method decode.

@Override
public OwsServiceCommunicationObject decode(XmlObject xmlObject) throws DecodingException {
    OwsServiceCommunicationObject request = null;
    LOGGER.debug("REQUESTTYPE:" + xmlObject.getClass());
    /*
         * Add O&M 1.0.0 namespace to GetObservation document. XmlBeans removes
         * the namespace from the document because there are no om:... elements
         * in the document. But the validation fails if the <resultModel>
         * element is set with e.g. om:Measurement.
         */
    if (xmlObject instanceof GetObservationDocument) {
        XmlCursor cursor = xmlObject.newCursor();
        cursor.toFirstChild();
        cursor.insertNamespace(OmConstants.NS_OM_PREFIX, OmConstants.NS_OM);
        cursor.dispose();
    }
    // validate document
    XmlHelper.validateDocument(xmlObject);
    if (xmlObject instanceof GetCapabilitiesDocument) {
        // getCapabilities request
        GetCapabilitiesDocument getCapsDoc = (GetCapabilitiesDocument) xmlObject;
        request = parseGetCapabilities(getCapsDoc);
    } else if (xmlObject instanceof DescribeSensorDocument) {
        // DescribeSensor request (still SOS 1.0 NS_URI
        DescribeSensorDocument descSensorDoc = (DescribeSensorDocument) xmlObject;
        request = parseDescribeSensor(descSensorDoc);
    } else if (xmlObject instanceof GetObservationDocument) {
        // getObservation request
        GetObservationDocument getObsDoc = (GetObservationDocument) xmlObject;
        request = parseGetObservation(getObsDoc);
    } else if (xmlObject instanceof GetFeatureOfInterestDocument) {
        // getFeatureOfInterest request
        GetFeatureOfInterestDocument getFoiDoc = (GetFeatureOfInterestDocument) xmlObject;
        request = parseGetFeatureOfInterest(getFoiDoc);
    } else if (xmlObject instanceof GetObservationByIdDocument) {
        // getObservationById request
        GetObservationByIdDocument getObsByIdDoc = (GetObservationByIdDocument) xmlObject;
        request = parseGetObservationById(getObsByIdDoc);
    } else {
        throw new UnsupportedDecoderXmlInputException(this, xmlObject);
    }
    return request;
}
Also used : OwsServiceCommunicationObject(org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject) GetObservationDocument(net.opengis.sos.x10.GetObservationDocument) DescribeSensorDocument(net.opengis.sos.x10.DescribeSensorDocument) GetFeatureOfInterestDocument(net.opengis.sos.x10.GetFeatureOfInterestDocument) GetObservationByIdDocument(net.opengis.sos.x10.GetObservationByIdDocument) UnsupportedDecoderXmlInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException) GetCapabilitiesDocument(net.opengis.sos.x10.GetCapabilitiesDocument) XmlCursor(org.apache.xmlbeans.XmlCursor)

Example 8 with UnsupportedDecoderXmlInputException

use of org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException in project arctic-sea by 52North.

the class FesDecoderv20 method parseBinaryLogicalFilter.

/**
 * parses a single binary logic filter of the requests and returns service
 * binary logic filter
 *
 * @param binaryLogicOpType
 *            XmlObject representing the binary logic filter
 * @return Service representation of binary logic filter
 * @throws DecodingException
 *             if creation of the BinaryLogicFilter failed or filter size is
 *             less than two
 */
private BinaryLogicFilter parseBinaryLogicalFilter(BinaryLogicOpType binaryLogicOpType) throws DecodingException {
    BinaryLogicFilter binaryLogicFilter = null;
    String localName = XmlHelper.getLocalName(binaryLogicOpType);
    if (localName.equals(BinaryLogicOperator.And.name())) {
        binaryLogicFilter = new BinaryLogicFilter(BinaryLogicOperator.And);
    } else if (localName.equals(BinaryLogicOperator.Or.name())) {
        binaryLogicFilter = new BinaryLogicFilter(BinaryLogicOperator.Or);
    } else {
        throw new UnsupportedDecoderXmlInputException(this, binaryLogicOpType);
    }
    Set<Filter<?>> filters = getFilterPredicates(binaryLogicOpType);
    if (filters.size() < 2) {
        throw new DecodingException("The binary logic filter requires minimla two filter predicates!");
    }
    binaryLogicFilter.addFilterPredicates(filters);
    return binaryLogicFilter;
}
Also used : Filter(org.n52.shetland.ogc.filter.Filter) TemporalFilter(org.n52.shetland.ogc.filter.TemporalFilter) SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) BinaryLogicFilter(org.n52.shetland.ogc.filter.BinaryLogicFilter) UnaryLogicFilter(org.n52.shetland.ogc.filter.UnaryLogicFilter) ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter) UnsupportedDecoderXmlInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) BinaryLogicFilter(org.n52.shetland.ogc.filter.BinaryLogicFilter)

Aggregations

UnsupportedDecoderXmlInputException (org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException)8 XmlObject (org.apache.xmlbeans.XmlObject)3 XmlCursor (org.apache.xmlbeans.XmlCursor)2 BBOXType (net.opengis.fes.x20.BBOXType)1 DescribeSensorDocument (net.opengis.sos.x10.DescribeSensorDocument)1 GetCapabilitiesDocument (net.opengis.sos.x10.GetCapabilitiesDocument)1 GetFeatureOfInterestDocument (net.opengis.sos.x10.GetFeatureOfInterestDocument)1 GetObservationByIdDocument (net.opengis.sos.x10.GetObservationByIdDocument)1 GetObservationDocument (net.opengis.sos.x10.GetObservationDocument)1 AbstractDataComponentDocument (net.opengis.swe.x20.AbstractDataComponentDocument)1 AbstractDataComponentType (net.opengis.swe.x20.AbstractDataComponentType)1 AnyScalarPropertyType (net.opengis.swe.x20.AnyScalarPropertyType)1 BooleanPropertyType (net.opengis.swe.x20.BooleanPropertyType)1 BooleanType (net.opengis.swe.x20.BooleanType)1 CategoryPropertyType (net.opengis.swe.x20.CategoryPropertyType)1 CategoryType (net.opengis.swe.x20.CategoryType)1 CountPropertyType (net.opengis.swe.x20.CountPropertyType)1 CountRangeType (net.opengis.swe.x20.CountRangeType)1 CountType (net.opengis.swe.x20.CountType)1 DataArrayDocument (net.opengis.swe.x20.DataArrayDocument)1