Search in sources :

Example 71 with DecodingException

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

the class SosDecoderv100 method parseGetObservationById.

private OwsServiceRequest parseGetObservationById(GetObservationByIdDocument getObsByIdDoc) throws DecodingException {
    GetObservationByIdRequest getObsByIdRequest = new GetObservationByIdRequest();
    GetObservationById getObsById = getObsByIdDoc.getGetObservationById();
    getObsByIdRequest.setService(getObsById.getService());
    getObsByIdRequest.setVersion(getObsById.getVersion());
    if (getObsById.isSetResponseFormat()) {
        getObsByIdRequest.setResponseFormat(decodeResponseFormat(getObsById.getResponseFormat()));
    } else {
        getObsByIdRequest.setResponseFormat(OmConstants.CONTENT_TYPE_OM.toString());
    }
    net.opengis.sos.x10.ResponseModeType.Enum responseMode = getObsById.getResponseMode();
    if (responseMode != null && responseMode.toString().equalsIgnoreCase(SosConstants.RESPONSE_MODE_INLINE)) {
        getObsByIdRequest.setResponseMode(SosConstants.RESPONSE_MODE_INLINE);
    }
    if (getObsById.isSetResultModel()) {
        getObsByIdRequest.setResultModel(OMHelper.getObservationTypeFor(getObsById.getResultModel()));
    }
    getObsByIdRequest.setObservationIdentifier(Arrays.asList(getObsById.getObservationId()));
    return getObsByIdRequest;
}
Also used : GetObservationById(net.opengis.sos.x10.GetObservationByIdDocument.GetObservationById) GetObservationByIdRequest(org.n52.shetland.ogc.sos.request.GetObservationByIdRequest)

Example 72 with DecodingException

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

the class SosDecoderv20 method parseInsertObservation.

private OwsServiceRequest parseInsertObservation(final InsertObservationDocument insertObservationDoc) throws DecodingException {
    // set namespace for default XML type (e.g. xs:string, xs:integer,
    // xs:boolean, ...)
    // Fix for problem with XmlBeans: namespace is not set in child elements
    // when defined in root of request (SOAP)
    final XmlCursor cursor = insertObservationDoc.newCursor();
    if (cursor.toFirstChild() && cursor.namespaceForPrefix(W3CConstants.NS_XS_PREFIX) == null) {
        cursor.prefixForNamespace(W3CConstants.NS_XS);
    }
    cursor.dispose();
    final InsertObservationRequest insertObservationRequest = new InsertObservationRequest();
    final InsertObservationType insertObservationType = insertObservationDoc.getInsertObservation();
    insertObservationRequest.setService(insertObservationType.getService());
    insertObservationRequest.setVersion(insertObservationType.getVersion());
    if (insertObservationDoc.getInsertObservation().getOfferingArray() != null) {
        insertObservationRequest.setOfferings(Arrays.asList(insertObservationType.getOfferingArray()));
    }
    insertObservationRequest.setExtensions(parseExtensibleRequest(insertObservationType));
    if (insertObservationType.getObservationArray() != null) {
        final int length = insertObservationType.getObservationArray().length;
        final Map<String, Time> phenomenonTimes = new HashMap<>(length);
        final Map<String, TimeInstant> resultTimes = new HashMap<>(length);
        final Map<String, AbstractFeature> features = new HashMap<>(length);
        CompositeException exceptions = new CompositeException();
        for (final Observation observation : insertObservationType.getObservationArray()) {
            final Object decodedObject = decodeXmlElement(observation.getOMObservation());
            if (decodedObject instanceof OmObservation) {
                final OmObservation sosObservation = (OmObservation) decodedObject;
                checkAndAddPhenomenonTime(sosObservation.getPhenomenonTime(), phenomenonTimes);
                checkAndAddResultTime(sosObservation.getResultTime(), resultTimes);
                checkAndAddFeatures(sosObservation.getObservationConstellation().getFeatureOfInterest(), features);
                insertObservationRequest.addObservation(sosObservation);
            } else {
                exceptions.add(new DecodingException(Sos2Constants.InsertObservationParams.observation, "The requested observation type (%s) is not supported by this server!", observation.getOMObservation().getDomNode().getNodeName()));
            }
        }
        checkReferencedElements(insertObservationRequest.getObservations(), phenomenonTimes, resultTimes, features);
        try {
            exceptions.throwIfNotEmpty();
        } catch (CompositeException ex) {
            throw new DecodingException(ex, Sos2Constants.InsertObservationParams.observation);
        }
    } else {
        // TODO MissingMandatoryParameterException?
        throw new DecodingException(Sos2Constants.InsertObservationParams.observation, "The request does not contain an observation");
    }
    return insertObservationRequest;
}
Also used : HashMap(java.util.HashMap) CompositeException(org.n52.janmayen.exception.CompositeException) OmObservation(org.n52.shetland.ogc.om.OmObservation) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) Time(org.n52.shetland.ogc.gml.time.Time) DecodingException(org.n52.svalbard.decode.exception.DecodingException) XmlString(org.apache.xmlbeans.XmlString) InsertObservationType(net.opengis.sos.x20.InsertObservationType) XmlCursor(org.apache.xmlbeans.XmlCursor) InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) OmObservation(org.n52.shetland.ogc.om.OmObservation) Observation(net.opengis.sos.x20.InsertObservationType.Observation) OwsServiceCommunicationObject(org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject) XmlObject(org.apache.xmlbeans.XmlObject) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 73 with DecodingException

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

the class SosDecoderv20 method parseGetResultResponse.

private OwsServiceResponse parseGetResultResponse(final GetResultResponseDocument getResultResponseDoc) throws DecodingException {
    final GetResultResponse sosGetResultResponse = new GetResultResponse();
    final GetResultResponseType getResultResponse = getResultResponseDoc.getGetResultResponse();
    final String resultValues = parseResultValues(getResultResponse.getResultValues());
    sosGetResultResponse.setResultValues(resultValues);
    return sosGetResultResponse;
}
Also used : GetResultResponseType(net.opengis.sos.x20.GetResultResponseType) GetResultResponse(org.n52.shetland.ogc.sos.response.GetResultResponse) XmlString(org.apache.xmlbeans.XmlString)

Example 74 with DecodingException

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

the class SosDecoderv20 method parseGetResultTemplate.

private OwsServiceRequest parseGetResultTemplate(final GetResultTemplateDocument getResultTemplateDoc) throws DecodingException {
    final GetResultTemplateType getResultTemplate = getResultTemplateDoc.getGetResultTemplate();
    final GetResultTemplateRequest sosGetResultTemplateRequest = new GetResultTemplateRequest();
    sosGetResultTemplateRequest.setService(getResultTemplate.getService());
    sosGetResultTemplateRequest.setVersion(getResultTemplate.getVersion());
    sosGetResultTemplateRequest.setOffering(getResultTemplate.getOffering());
    sosGetResultTemplateRequest.setObservedProperty(getResultTemplate.getObservedProperty());
    sosGetResultTemplateRequest.setExtensions(parseExtensibleRequest(getResultTemplate));
    return sosGetResultTemplateRequest;
}
Also used : GetResultTemplateType(net.opengis.sos.x20.GetResultTemplateType) GetResultTemplateRequest(org.n52.shetland.ogc.sos.request.GetResultTemplateRequest)

Example 75 with DecodingException

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

the class SosDecoderv20 method parseGetResultTemplateResponse.

private OwsServiceResponse parseGetResultTemplateResponse(final GetResultTemplateResponseDocument getResultTemplateResponseDoc) throws DecodingException {
    final GetResultTemplateResponse sosGetResultTemplateResponse = new GetResultTemplateResponse();
    final GetResultTemplateResponseType getResultTemplateResponse = getResultTemplateResponseDoc.getGetResultTemplateResponse();
    final SosResultEncoding resultEncoding = parseResultEncoding(getResultTemplateResponse.getResultEncoding().getAbstractEncoding());
    final SosResultStructure resultStructure = parseResultStructure(getResultTemplateResponse.getResultStructure().getAbstractDataComponent());
    sosGetResultTemplateResponse.setResultEncoding(resultEncoding);
    sosGetResultTemplateResponse.setResultStructure(resultStructure);
    return sosGetResultTemplateResponse;
}
Also used : GetResultTemplateResponseType(net.opengis.sos.x20.GetResultTemplateResponseType) GetResultTemplateResponse(org.n52.shetland.ogc.sos.response.GetResultTemplateResponse) SosResultEncoding(org.n52.shetland.ogc.sos.SosResultEncoding) SosResultStructure(org.n52.shetland.ogc.sos.SosResultStructure)

Aggregations

Test (org.junit.Test)92 DecodingException (org.n52.svalbard.decode.exception.DecodingException)63 XmlObject (org.apache.xmlbeans.XmlObject)52 JsonNode (com.fasterxml.jackson.databind.JsonNode)25 SweField (org.n52.shetland.ogc.swe.SweField)25 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)23 XmlException (org.apache.xmlbeans.XmlException)23 GetObservationRequest (org.n52.shetland.ogc.sos.request.GetObservationRequest)22 UnsupportedDecoderInputException (org.n52.svalbard.decode.exception.UnsupportedDecoderInputException)21 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)13 SystemType (net.opengis.sensorML.x101.SystemType)12 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)12 Before (org.junit.Before)11 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)11 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)10 DateTime (org.joda.time.DateTime)10 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)10 XmlString (org.apache.xmlbeans.XmlString)9 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)8 Geometry (org.locationtech.jts.geom.Geometry)8