Search in sources :

Example 16 with UnsupportedDecoderInputException

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

the class CapabilitiesDocumentDecoder method decode.

@Override
@SuppressFBWarnings("NP_LOAD_OF_KNOWN_NULL_VALUE")
public GetCapabilitiesResponse decode(CapabilitiesDocument cd) throws DecodingException {
    if (cd != null) {
        GetCapabilitiesResponse response = new GetCapabilitiesResponse();
        OwsCapabilities capabilities = (OwsCapabilities) decodeXmlObject(cd.getCapabilities());
        response.setCapabilities(capabilities);
        return response;
    }
    throw new UnsupportedDecoderInputException(this, cd);
}
Also used : GetCapabilitiesResponse(org.n52.shetland.ogc.ows.service.GetCapabilitiesResponse) OwsCapabilities(org.n52.shetland.ogc.ows.OwsCapabilities) UnsupportedDecoderInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderInputException) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 17 with UnsupportedDecoderInputException

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

the class DeleteObservationDecoder method decode.

@Override
public DeleteObservationRequest decode(XmlObject xmlObject) throws DecodingException {
    LOGGER.debug("REQUESTTYPE: {}", xmlObject != null ? xmlObject.getClass() : "null recevied");
    // XmlHelper.validateDocument(xmlObject);
    if (xmlObject instanceof DeleteObservationDocument) {
        DeleteObservationDocument delObsDoc = (DeleteObservationDocument) xmlObject;
        DeleteObservationRequest decodedRequest = parseDeleteObservation(delObsDoc);
        LOGGER.debug("Decoded request: {}", decodedRequest);
        return decodedRequest;
    } else {
        throw new UnsupportedDecoderInputException(this, xmlObject);
    }
}
Also used : DeleteObservationRequest(org.n52.shetland.ogc.sos.delobs.DeleteObservationRequest) DeleteObservationDocument(net.opengis.sosdo.x10.DeleteObservationDocument) UnsupportedDecoderInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderInputException)

Example 18 with UnsupportedDecoderInputException

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

the class DocumentCitationTypeDecoder method decode.

@Override
public DocumentCitation decode(XmlObject xmlObject) throws DecodingException {
    if (xmlObject instanceof DocumentCitationType) {
        DocumentCitation documentCitation = new DocumentCitation();
        DocumentCitationType dct = (DocumentCitationType) xmlObject;
        documentCitation.setDescription(dct.getDescription().getStringValue());
        if (dct.isNilDate()) {
            if (dct.getDate().isSetNilReason()) {
                documentCitation.setDate(Nillable.<DateTime>nil(dct.getDate().getNilReason().toString()));
            }
        } else {
            documentCitation.setDate(new DateTime(dct.getDate().getCIDate().getDate().getDate().getTime()));
        }
        if (dct.getLinkArray() != null) {
            for (Link link : dct.getLinkArray()) {
                if (link.isNil() && link.isSetNilReason()) {
                    documentCitation.addLink(Nillable.<String>nil(link.getNilReason().toString()));
                } else {
                    documentCitation.addLink(link.getStringValue());
                }
            }
        }
        return documentCitation;
    }
    throw new UnsupportedDecoderInputException(this, xmlObject);
}
Also used : DocumentCitationType(eu.europa.ec.inspire.schemas.base2.x20.DocumentCitationType) DocumentCitation(org.n52.shetland.inspire.base2.DocumentCitation) UnsupportedDecoderInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderInputException) DateTime(org.joda.time.DateTime) Link(eu.europa.ec.inspire.schemas.base2.x20.DocumentCitationType.Link)

Example 19 with UnsupportedDecoderInputException

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

the class AbstractGmlDecoderv321 method parseNamedValueValue.

protected NamedValue<?> parseNamedValueValue(XmlObject xml) throws DecodingException {
    XmlObject xmlObject = xml;
    if (xmlObject.schemaType() == XmlAnyTypeImpl.type) {
        try {
            xmlObject = XmlObject.Factory.parse(xml.xmlText().trim());
        } catch (XmlException e) {
            LOGGER.error("Error while parsing NamedValueValue", e);
        }
    }
    Object value;
    if (XmlBoolean.Factory.newInstance().schemaType().equals(xmlObject.schemaType())) {
        value = ((XmlBoolean) xmlObject).getBooleanValue();
    } else if (XmlString.Factory.newInstance().schemaType().equals(xmlObject.schemaType())) {
        value = ((XmlString) xmlObject).getStringValue();
    } else if (XmlInt.Factory.newInstance().schemaType().equals(xmlObject.schemaType())) {
        value = ((XmlInt) xmlObject).getIntValue();
    } else if (XmlInteger.Factory.newInstance().schemaType().equals(xmlObject.schemaType())) {
        value = ((XmlInteger) xmlObject).getBigIntegerValue().intValue();
    } else if (XmlDouble.Factory.newInstance().schemaType().equals(xmlObject.schemaType())) {
        value = ((XmlDouble) xmlObject).getDoubleValue();
    } else {
        value = decodeXmlObject(xmlObject);
    }
    if (value instanceof BooleanValue) {
        NamedValue<Boolean> namedValue = new NamedValue<>();
        namedValue.setValue((BooleanValue) value);
        return namedValue;
    } else if (value instanceof SweBoolean) {
        NamedValue<Boolean> namedValue = new NamedValue<>();
        namedValue.setValue(new BooleanValue(((SweBoolean) value).getValue()));
        return namedValue;
    } else if (value instanceof Boolean) {
        NamedValue<Boolean> namedValue = new NamedValue<>();
        namedValue.setValue(new BooleanValue((Boolean) value));
        return namedValue;
    } else if (value instanceof CategoryValue) {
        NamedValue<String> namedValue = new NamedValue<>();
        namedValue.setValue((CategoryValue) value);
        return namedValue;
    } else if (value instanceof SweCategory) {
        NamedValue<String> namedValue = new NamedValue<>();
        namedValue.setValue(new CategoryValue(((SweCategory) value).getValue(), ((SweCategory) value).getCodeSpace()));
        return namedValue;
    } else if (value instanceof CountValue) {
        NamedValue<Integer> namedValue = new NamedValue<>();
        namedValue.setValue((CountValue) value);
        return namedValue;
    } else if (value instanceof SweCount) {
        NamedValue<Integer> namedValue = new NamedValue<>();
        namedValue.setValue(new CountValue(((SweCount) value).getValue()));
        return namedValue;
    } else if (value instanceof Integer) {
        NamedValue<Integer> namedValue = new NamedValue<>();
        namedValue.setValue(new CountValue((Integer) value));
        return namedValue;
    } else if (value instanceof GeometryValue) {
        NamedValue<Geometry> namedValue = new NamedValue<>();
        namedValue.setValue((GeometryValue) value);
        return namedValue;
    } else if (value instanceof QuantityValue) {
        NamedValue<BigDecimal> namedValue = new NamedValue<>();
        namedValue.setValue((QuantityValue) value);
        return namedValue;
    } else if (value instanceof GmlMeasureType) {
        NamedValue<BigDecimal> namedValue = new NamedValue<>();
        namedValue.setValue(new QuantityValue(((GmlMeasureType) value).getValue(), ((GmlMeasureType) value).getUnit()));
        return namedValue;
    } else if (value instanceof SweQuantity) {
        NamedValue<BigDecimal> namedValue = new NamedValue<>();
        namedValue.setValue(new QuantityValue(((SweQuantity) value).getValue(), ((SweQuantity) value).getUom()));
        return namedValue;
    } else if (value instanceof Double) {
        NamedValue<BigDecimal> namedValue = new NamedValue<>();
        namedValue.setValue(new QuantityValue((Double) value));
        return namedValue;
    } else if (value instanceof TextValue) {
        NamedValue<String> namedValue = new NamedValue<>();
        namedValue.setValue((TextValue) value);
        return namedValue;
    } else if (value instanceof SweText) {
        NamedValue<String> namedValue = new NamedValue<>();
        namedValue.setValue(new TextValue(((SweText) value).getValue()));
        return namedValue;
    } else if (value instanceof String) {
        NamedValue<String> namedValue = new NamedValue<>();
        namedValue.setValue(new TextValue((String) value));
        return namedValue;
    } else if (value instanceof AbstractGeometry) {
        NamedValue<Geometry> namedValue = new NamedValue<>();
        namedValue.setValue(new GeometryValue((AbstractGeometry) value));
        return namedValue;
    } else if (value instanceof org.n52.shetland.ogc.gml.ReferenceType) {
        NamedValue<org.n52.shetland.ogc.gml.ReferenceType> namedValue = new NamedValue<>();
        namedValue.setValue(new ReferenceValue((org.n52.shetland.ogc.gml.ReferenceType) value));
        return namedValue;
    } else if (value instanceof W3CHrefAttribute) {
        NamedValue<W3CHrefAttribute> namedValue = new NamedValue<>();
        namedValue.setValue(new HrefAttributeValue((W3CHrefAttribute) value));
        return namedValue;
    } else {
        throw new UnsupportedDecoderInputException(this, xmlObject);
    }
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) AbstractGeometry(org.n52.shetland.ogc.gml.AbstractGeometry) ReferenceValue(org.n52.shetland.ogc.om.values.ReferenceValue) NamedValue(org.n52.shetland.ogc.om.NamedValue) XmlString(org.apache.xmlbeans.XmlString) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) CountValue(org.n52.shetland.ogc.om.values.CountValue) BooleanValue(org.n52.shetland.ogc.om.values.BooleanValue) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) XmlBoolean(org.apache.xmlbeans.XmlBoolean) HrefAttributeValue(org.n52.shetland.ogc.om.values.HrefAttributeValue) XmlString(org.apache.xmlbeans.XmlString) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) W3CHrefAttribute(org.n52.shetland.w3c.xlink.W3CHrefAttribute) XmlDouble(org.apache.xmlbeans.XmlDouble) UnsupportedDecoderInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderInputException) BigDecimal(java.math.BigDecimal) XmlInteger(org.apache.xmlbeans.XmlInteger) Geometry(org.locationtech.jts.geom.Geometry) AbstractGeometry(org.n52.shetland.ogc.gml.AbstractGeometry) GeometryValue(org.n52.shetland.ogc.om.values.GeometryValue) XmlException(org.apache.xmlbeans.XmlException) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) TextValue(org.n52.shetland.ogc.om.values.TextValue) CategoryValue(org.n52.shetland.ogc.om.values.CategoryValue) XmlObject(org.apache.xmlbeans.XmlObject) XmlObject(org.apache.xmlbeans.XmlObject) GmlMeasureType(org.n52.shetland.ogc.gml.GmlMeasureType)

Example 20 with UnsupportedDecoderInputException

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

the class InsertFeatureOfInterestDecoder method decode.

public InsertFeatureOfInterestRequest decode(XmlObject xmlObject) throws DecodingException {
    LOGGER.debug(String.format("REQUESTTYPE: %s", xmlObject != null ? xmlObject.getClass() : "null recevied"));
    // XmlHelper.validateDocument(xmlObject);
    if (xmlObject instanceof InsertFeatureOfInterestDocument) {
        InsertFeatureOfInterestDocument ifoid = (InsertFeatureOfInterestDocument) xmlObject;
        InsertFeatureOfInterestRequest decodedRequest = parseInsertFeatureOfInterest(ifoid);
        LOGGER.debug(String.format("Decoded request: %s", decodedRequest));
        return decodedRequest;
    } else {
        throw new UnsupportedDecoderInputException(this, xmlObject);
    }
}
Also used : InsertFeatureOfInterestDocument(net.opengis.ifoi.x10.InsertFeatureOfInterestDocument) InsertFeatureOfInterestRequest(org.n52.shetland.ogc.sos.ifoi.InsertFeatureOfInterestRequest) UnsupportedDecoderInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderInputException)

Aggregations

UnsupportedDecoderInputException (org.n52.svalbard.decode.exception.UnsupportedDecoderInputException)21 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)7 OwsCapabilities (org.n52.shetland.ogc.ows.OwsCapabilities)4 XmlObject (org.apache.xmlbeans.XmlObject)3 DecodingException (org.n52.svalbard.decode.exception.DecodingException)3 FilterCapabilities (org.n52.shetland.ogc.filter.FilterCapabilities)2 NamedValue (org.n52.shetland.ogc.om.NamedValue)2 GetCapabilitiesResponse (org.n52.shetland.ogc.ows.service.GetCapabilitiesResponse)2 SosCapabilities (org.n52.shetland.ogc.sos.SosCapabilities)2 SosObservationOffering (org.n52.shetland.ogc.sos.SosObservationOffering)2 DeleteObservationRequest (org.n52.shetland.ogc.sos.delobs.DeleteObservationRequest)2 DocumentCitationType (eu.europa.ec.inspire.schemas.base2.x20.DocumentCitationType)1 Link (eu.europa.ec.inspire.schemas.base2.x20.DocumentCitationType.Link)1 RelatedPartyType (eu.europa.ec.inspire.schemas.base2.x20.RelatedPartyType)1 BigDecimal (java.math.BigDecimal)1 DeleteResultTemplateDocument (net.opengis.drt.x10.DeleteResultTemplateDocument)1 ReferenceType (net.opengis.gml.x32.ReferenceType)1 InsertFeatureOfInterestDocument (net.opengis.ifoi.x10.InsertFeatureOfInterestDocument)1 NamedValueType (net.opengis.om.x20.NamedValueType)1 GetFeatureOfInterestResponseType (net.opengis.sos.x20.GetFeatureOfInterestResponseType)1