Search in sources :

Example 6 with SchemaLocation

use of org.n52.shetland.w3c.SchemaLocation in project arctic-sea by 52North.

the class EReportingHeaderEncoder method write.

@Override
public void write() throws XMLStreamException, EncodingException {
    EReportingHeader h = getElement();
    start(AqdConstants.QN_AQD_REPORTING_HEADER);
    namespace(AqdConstants.NS_AD_PREFIX, AqdConstants.NS_AD);
    namespace(AqdConstants.NS_AQD_PREFIX, AqdConstants.NS_AQD);
    namespace(AqdConstants.NS_BASE_PREFIX, AqdConstants.NS_BASE);
    namespace(AqdConstants.NS_BASE2_PREFIX, AqdConstants.NS_BASE2);
    namespace(AqdConstants.NS_GN_PREFIX, AqdConstants.NS_GN);
    namespace(GmlConstants.NS_GML_PREFIX, GmlConstants.NS_GML_32);
    namespace(W3CConstants.NS_XLINK_PREFIX, W3CConstants.NS_XLINK);
    namespace(W3CConstants.NS_XSI_PREFIX, W3CConstants.NS_XSI);
    namespace(GcoConstants.NS_GCO_PREFIX, GcoConstants.NS_GCO);
    if (isAddSchemaLocation()) {
        schemaLocation(Collections.singleton(AqdConstants.NS_AQD_SCHEMA_LOCATION));
    }
    attr(GmlConstants.QN_ID_32, getGMLId(h));
    encodeChange(h.getChange());
    encodeInpireID(h.getInspireID());
    encodeReportingAuthority(h.getReportingAuthority());
    encodeReportingPeriod(h.getReportingPeriod());
    if (h.isSetContent()) {
        encodeContent(h.getContent());
    }
    end(AqdConstants.QN_AQD_REPORTING_HEADER);
}
Also used : EReportingHeader(org.n52.shetland.aqd.EReportingHeader)

Example 7 with SchemaLocation

use of org.n52.shetland.w3c.SchemaLocation in project arctic-sea by 52North.

the class GetDataAvailabilityStreamWriter method writeGetDataAvailabilityResponse.

@Override
protected void writeGetDataAvailabilityResponse() throws XMLStreamException, EncodingException {
    start(GetDataAvailabilityConstants.GDA_GET_DATA_AVAILABILITY_RESPONSE);
    namespace(GetDataAvailabilityConstants.NS_GDA_PREFIX, GetDataAvailabilityConstants.NS_GDA);
    namespace(GmlConstants.NS_GML_PREFIX, GmlConstants.NS_GML_32);
    namespace(SweConstants.NS_SWE_PREFIX, SweConstants.NS_SWE_20);
    namespace(W3CConstants.NS_XLINK_PREFIX, W3CConstants.NS_XLINK);
    schemaLocation(Sets.newHashSet(GetDataAvailabilityConstants.GET_DATA_AVAILABILITY_SCHEMA_LOCATION));
    for (DataAvailability da : getElement()) {
        wirteDataAvailabilityMember(da);
    }
    end(GetDataAvailabilityConstants.GDA_GET_DATA_AVAILABILITY_RESPONSE);
}
Also used : DataAvailability(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.DataAvailability)

Example 8 with SchemaLocation

use of org.n52.shetland.w3c.SchemaLocation in project arctic-sea by 52North.

the class Soap12XmlStreamWriter method getSchemaLocation.

protected Set<SchemaLocation> getSchemaLocation() throws EncodingException, XMLStreamException {
    SoapResponse response = getElement();
    Set<SchemaLocation> schemaLocations = Sets.newHashSet();
    schemaLocations.add(SoapConstants.SOAP_12_SCHEMA_LOCATION);
    if (response.isSetBodyContent()) {
        Encoder<Object, OwsServiceResponse> encoder = getEncoder(response.getBodyContent());
        if (encoder != null && encoder instanceof SchemaAwareEncoder) {
            schemaLocations.addAll(((SchemaAwareEncoder<?, ?>) encoder).getSchemaLocations());
        }
    }
    return schemaLocations;
}
Also used : SchemaLocation(org.n52.shetland.w3c.SchemaLocation) SchemaAwareEncoder(org.n52.svalbard.encode.SchemaAwareEncoder) SoapResponse(org.n52.shetland.w3c.soap.SoapResponse) XmlObject(org.apache.xmlbeans.XmlObject) OwsServiceResponse(org.n52.shetland.ogc.ows.service.OwsServiceResponse)

Example 9 with SchemaLocation

use of org.n52.shetland.w3c.SchemaLocation in project arctic-sea by 52North.

the class Soap12Encoder method createSOAP12Envelope.

private XmlObject createSOAP12Envelope(SoapResponse response, EncodingContext additionalValues) throws EncodingException {
    String action = null;
    final EnvelopeDocument envelopeDoc = EnvelopeDocument.Factory.newInstance();
    final Envelope envelope = envelopeDoc.addNewEnvelope();
    final Body body = envelope.addNewBody();
    if (response.getSoapFault() != null) {
        body.set(createSOAP12Fault(response.getSoapFault()));
    } else {
        if (response.getException() != null) {
            if (!response.getException().getExceptions().isEmpty()) {
                final CodedException firstException = response.getException().getExceptions().get(0);
                action = getExceptionActionURI(firstException.getCode());
            }
            body.set(createSOAP12FaultFromExceptionResponse(response.getException()));
            N52XmlHelper.setSchemaLocationsToDocument(envelopeDoc, Sets.newHashSet(N52XmlHelper.getSchemaLocationForSOAP12(), N52XmlHelper.getSchemaLocationForOWS110Exception()));
        } else {
            action = response.getSoapAction();
            final XmlObject bodyContent = getBodyContent(response);
            String value = null;
            Node nodeToRemove = null;
            final NamedNodeMap attributeMap = bodyContent.getDomNode().getFirstChild().getAttributes();
            for (int i = 0; i < attributeMap.getLength(); i++) {
                final Node node = attributeMap.item(i);
                if (node.getLocalName().equals(W3CConstants.AN_SCHEMA_LOCATION)) {
                    value = node.getNodeValue();
                    nodeToRemove = node;
                }
            }
            if (nodeToRemove != null) {
                attributeMap.removeNamedItem(nodeToRemove.getNodeName());
            }
            final Set<SchemaLocation> schemaLocations = Sets.newHashSet();
            schemaLocations.add(N52XmlHelper.getSchemaLocationForSOAP12());
            if (value != null && !value.isEmpty()) {
                String[] split = value.split(" ");
                for (int i = 0; i < split.length; i += 2) {
                    schemaLocations.add(new SchemaLocation(split[i], split[i + 1]));
                }
            }
            N52XmlHelper.setSchemaLocationsToDocument(envelopeDoc, schemaLocations);
            body.set(bodyContent);
        }
    }
    if (response.getHeader() != null) {
        createSOAP12Header(envelope, response.getHeader(), action);
    } else {
        envelope.addNewHeader();
    }
    // checkAndValidateSoapMessage(envelopeDoc);
    return envelopeDoc;
}
Also used : SchemaLocation(org.n52.shetland.w3c.SchemaLocation) EnvelopeDocument(org.w3.x2003.x05.soapEnvelope.EnvelopeDocument) NamedNodeMap(org.w3c.dom.NamedNodeMap) CodedException(org.n52.shetland.ogc.ows.exception.CodedException) Node(org.w3c.dom.Node) XmlObject(org.apache.xmlbeans.XmlObject) XmlString(org.apache.xmlbeans.XmlString) Envelope(org.w3.x2003.x05.soapEnvelope.Envelope) Body(org.w3.x2003.x05.soapEnvelope.Body)

Example 10 with SchemaLocation

use of org.n52.shetland.w3c.SchemaLocation in project arctic-sea by 52North.

the class DescribeSensorResponseEncoderTest method should_return_correct_schema_location.

@Test
public void should_return_correct_schema_location() {
    assertThat(new DescribeSensorResponseEncoder().getSchemaLocations().size(), is(1));
    SchemaLocation schemLoc = new DescribeSensorResponseEncoder().getSchemaLocations().iterator().next();
    assertThat(schemLoc.getNamespace(), is("http://www.opengis.net/swes/2.0"));
    assertThat(schemLoc.getSchemaFileUrl(), is("http://schemas.opengis.net/swes/2.0/swes.xsd"));
}
Also used : SchemaLocation(org.n52.shetland.w3c.SchemaLocation) DescribeSensorResponseEncoder(org.n52.svalbard.encode.DescribeSensorResponseEncoder) Test(org.junit.Test)

Aggregations

SchemaLocation (org.n52.shetland.w3c.SchemaLocation)5 XmlObject (org.apache.xmlbeans.XmlObject)3 Test (org.junit.Test)3 ObservationStream (org.n52.shetland.ogc.om.ObservationStream)2 OmObservation (org.n52.shetland.ogc.om.OmObservation)2 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)2 DataAvailability (org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.DataAvailability)2 EncodingException (org.n52.svalbard.encode.exception.EncodingException)2 NoSuchElementException (java.util.NoSuchElementException)1 OMObservationDocument (net.opengis.om.x20.OMObservationDocument)1 CollectionDocument (net.opengis.waterml.x20.CollectionDocument)1 CollectionType (net.opengis.waterml.x20.CollectionType)1 XmlString (org.apache.xmlbeans.XmlString)1 EReportingHeader (org.n52.shetland.aqd.EReportingHeader)1 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)1 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)1 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)1 AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)1 WmlMonitoringPoint (org.n52.shetland.ogc.om.series.wml.WmlMonitoringPoint)1 CodedException (org.n52.shetland.ogc.ows.exception.CodedException)1