Search in sources :

Example 56 with If

use of org.w3._2007.rif.If in project arctic-sea by 52North.

the class Iso19139GmdEncoder method encodeContact.

private void encodeContact(CIContactPropertyType cicpt, Referenceable<CiContact> referenceable) {
    if (referenceable.isReference()) {
        Reference reference = referenceable.getReference();
        reference.getActuate().map(Actuate::toString).map(ActuateType.Enum::forString).ifPresent(cicpt::setActuate);
        reference.getArcrole().ifPresent(cicpt::setArcrole);
        reference.getHref().map(URI::toString).ifPresent(cicpt::setHref);
        reference.getRole().ifPresent(cicpt::setRole);
        reference.getShow().map(Show::toString).map(ShowType.Enum::forString).ifPresent(cicpt::setShow);
        reference.getTitle().ifPresent(cicpt::setTitle);
        reference.getType().map(Type::toString).map(TypeType.Enum::forString).ifPresent(cicpt::setType);
    } else {
        if (referenceable.isInstance()) {
            Nillable<CiContact> nillable = referenceable.getInstance();
            if (nillable.isPresent()) {
                CiContact ciContact = referenceable.getInstance().get();
                CIContactType cict = cicpt.addNewCIContact();
                if (ciContact.getAddress() != null) {
                    encodeCiAddress(cict.addNewAddress(), ciContact.getAddress());
                }
                if (ciContact.getContactInstructionsNillable() != null) {
                    if (ciContact.getContactInstructionsNillable().isPresent()) {
                        cict.addNewContactInstructions().setCharacterString(ciContact.getContactInstructions());
                    } else if (ciContact.getContactInstructionsNillable().hasReason()) {
                        cict.addNewContactInstructions().setNilReason(ciContact.getContactInstructionsNillable().getNilReason().get());
                    }
                }
                if (ciContact.isSetHoursOfService()) {
                    if (ciContact.getHoursOfServiceNillable().isPresent()) {
                        cict.addNewHoursOfService().setCharacterString(ciContact.getHoursOfService());
                    } else if (ciContact.getHoursOfServiceNillable().hasReason()) {
                        cict.addNewHoursOfService().setNilReason(ciContact.getHoursOfServiceNillable().getNilReason().get());
                    }
                }
                if (ciContact.getOnlineResourceReferenceable() != null) {
                    encodeOnlineResource(cict.addNewOnlineResource(), ciContact.getOnlineResourceReferenceable());
                }
                if (ciContact.isSetPhone()) {
                    encodePhone(cict.addNewPhone(), ciContact.getPhone());
                }
            } else {
                if (nillable.hasReason()) {
                    cicpt.setNilReason(nillable.getNilReason().get());
                }
            }
        }
    }
}
Also used : ActuateType(org.w3.x1999.xlink.ActuateType) Actuate(org.n52.shetland.w3c.xlink.Actuate) CIAddressType(org.isotc211.x2005.gmd.CIAddressType) CIContactPropertyType(org.isotc211.x2005.gmd.CIContactPropertyType) DQDomainConsistencyPropertyType(org.isotc211.x2005.gmd.DQDomainConsistencyPropertyType) CodeType(net.opengis.gml.x32.CodeType) MDMetadataPropertyType(org.isotc211.x2005.gmd.MDMetadataPropertyType) MDMetadataType(org.isotc211.x2005.gmd.MDMetadataType) LocalisedCharacterStringPropertyType(org.isotc211.x2005.gmd.LocalisedCharacterStringPropertyType) CharacterStringPropertyType(org.isotc211.x2005.gco.CharacterStringPropertyType) EXExtentPropertyType(org.isotc211.x2005.gmd.EXExtentPropertyType) CICitationType(org.isotc211.x2005.gmd.CICitationType) MDDataIdentificationType(org.isotc211.x2005.gmd.MDDataIdentificationType) DQDomainConsistencyType(org.isotc211.x2005.gmd.DQDomainConsistencyType) EXVerticalExtentType(org.isotc211.x2005.gmd.EXVerticalExtentType) GmdDateType(org.n52.shetland.iso.gmd.GmdDateType) CodeListValueType(org.isotc211.x2005.gco.CodeListValueType) AbstractCRSType(net.opengis.gml.x32.AbstractCRSType) DQResultPropertyType(org.isotc211.x2005.gmd.DQResultPropertyType) CIDateType(org.isotc211.x2005.gmd.CIDateType) CIContactType(org.isotc211.x2005.gmd.CIContactType) ShowType(org.w3.x1999.xlink.ShowType) MDIdentificationPropertyType(org.isotc211.x2005.gmd.MDIdentificationPropertyType) EXExtentType(org.isotc211.x2005.gmd.EXExtentType) CIOnlineResourcePropertyType(org.isotc211.x2005.gmd.CIOnlineResourcePropertyType) BaseUnitType(net.opengis.gml.x32.BaseUnitType) CITelephonePropertyType(org.isotc211.x2005.gmd.CITelephonePropertyType) ActuateType(org.w3.x1999.xlink.ActuateType) CIAddressPropertyType(org.isotc211.x2005.gmd.CIAddressPropertyType) UnitOfMeasurePropertyType(org.isotc211.x2005.gco.UnitOfMeasurePropertyType) EXVerticalExtentPropertyType(org.isotc211.x2005.gmd.EXVerticalExtentPropertyType) CIOnlineResourceType(org.isotc211.x2005.gmd.CIOnlineResourceType) DQQuantitativeResultType(org.isotc211.x2005.gmd.DQQuantitativeResultType) CIResponsiblePartyType(org.isotc211.x2005.gmd.CIResponsiblePartyType) SupportedType(org.n52.shetland.ogc.SupportedType) LocalisedCharacterStringType(org.isotc211.x2005.gmd.LocalisedCharacterStringType) CICitationPropertyType(org.isotc211.x2005.gmd.CICitationPropertyType) CITelephoneType(org.isotc211.x2005.gmd.CITelephoneType) DQConformanceResultType(org.isotc211.x2005.gmd.DQConformanceResultType) TypeType(org.w3.x1999.xlink.TypeType) Type(org.n52.shetland.w3c.xlink.Type) CIRoleCodePropertyType(org.isotc211.x2005.gmd.CIRoleCodePropertyType) MDDataIdentificationPropertyType(org.isotc211.x2005.gmd.MDDataIdentificationPropertyType) RealPropertyType(org.isotc211.x2005.gco.RealPropertyType) AbstractMDIdentificationType(org.isotc211.x2005.gmd.AbstractMDIdentificationType) PTFreeTextType(org.isotc211.x2005.gmd.PTFreeTextType) SCCRSPropertyType(org.isotc211.x2005.gsr.SCCRSPropertyType) CIResponsiblePartyPropertyType(org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType) Reference(org.n52.shetland.w3c.xlink.Reference) CIContactType(org.isotc211.x2005.gmd.CIContactType) Show(org.n52.shetland.w3c.xlink.Show) TypeType(org.w3.x1999.xlink.TypeType) CiContact(org.n52.shetland.iso.gmd.CiContact) ShowType(org.w3.x1999.xlink.ShowType)

Example 57 with If

use of org.w3._2007.rif.If in project arctic-sea by 52North.

the class Iso19139GmdEncoder method encodeCiAddress.

private void encodeCiAddress(CIAddressPropertyType ciapt, Referenceable<CiAddress> referenceable) {
    if (referenceable.isReference()) {
        Reference reference = referenceable.getReference();
        reference.getActuate().map(Actuate::toString).map(ActuateType.Enum::forString).ifPresent(ciapt::setActuate);
        reference.getArcrole().ifPresent(ciapt::setArcrole);
        reference.getHref().map(URI::toString).ifPresent(ciapt::setHref);
        reference.getRole().ifPresent(ciapt::setRole);
        reference.getShow().map(Show::toString).map(ShowType.Enum::forString).ifPresent(ciapt::setShow);
        reference.getTitle().ifPresent(ciapt::setTitle);
        reference.getType().map(Type::toString).map(TypeType.Enum::forString).ifPresent(ciapt::setType);
    } else {
        if (referenceable.isInstance()) {
            Nillable<CiAddress> nillable = referenceable.getInstance();
            if (nillable.isPresent()) {
                CiAddress ciAddress = referenceable.getInstance().get();
                CIAddressType ciat = ciapt.addNewCIAddress();
                if (ciAddress.isSetAdministrativeArea()) {
                    ciat.addNewAdministrativeArea().setCharacterString(ciAddress.getAdministrativeArea());
                }
                if (ciAddress.isSetCity()) {
                    ciat.addNewCity().setCharacterString(ciAddress.getCity());
                }
                if (ciAddress.isSetCountry()) {
                    ciat.addNewCountry().setCharacterString(ciAddress.getCountry());
                }
                if (ciAddress.isSetPostalCode()) {
                    ciat.addNewPostalCode().setCharacterString(ciAddress.getPostalCode());
                }
                if (ciAddress.hasDeliveryPoints()) {
                    ciat.setDeliveryPointArray(listToCharacterStringPropertyTypeArray(ciAddress.getDeliveryPoints()));
                }
                if (ciAddress.hasElectronicMailAddresses()) {
                    ciat.setElectronicMailAddressArray(listToCharacterStringPropertyTypeArray(Lists.newArrayList(ciAddress.getElectronicMailAddresses())));
                }
                if (ciAddress.isSetId()) {
                    ciat.setId(ciAddress.getId());
                }
                if (ciAddress.isSetUuid()) {
                    ciat.setUuid(ciAddress.getUuid());
                }
            } else {
                if (nillable.hasReason()) {
                    ciapt.setNilReason(nillable.getNilReason().get());
                }
            }
        }
    }
}
Also used : ActuateType(org.w3.x1999.xlink.ActuateType) Actuate(org.n52.shetland.w3c.xlink.Actuate) CIAddressType(org.isotc211.x2005.gmd.CIAddressType) CIContactPropertyType(org.isotc211.x2005.gmd.CIContactPropertyType) DQDomainConsistencyPropertyType(org.isotc211.x2005.gmd.DQDomainConsistencyPropertyType) CodeType(net.opengis.gml.x32.CodeType) MDMetadataPropertyType(org.isotc211.x2005.gmd.MDMetadataPropertyType) MDMetadataType(org.isotc211.x2005.gmd.MDMetadataType) LocalisedCharacterStringPropertyType(org.isotc211.x2005.gmd.LocalisedCharacterStringPropertyType) CharacterStringPropertyType(org.isotc211.x2005.gco.CharacterStringPropertyType) EXExtentPropertyType(org.isotc211.x2005.gmd.EXExtentPropertyType) CICitationType(org.isotc211.x2005.gmd.CICitationType) MDDataIdentificationType(org.isotc211.x2005.gmd.MDDataIdentificationType) DQDomainConsistencyType(org.isotc211.x2005.gmd.DQDomainConsistencyType) EXVerticalExtentType(org.isotc211.x2005.gmd.EXVerticalExtentType) GmdDateType(org.n52.shetland.iso.gmd.GmdDateType) CodeListValueType(org.isotc211.x2005.gco.CodeListValueType) AbstractCRSType(net.opengis.gml.x32.AbstractCRSType) DQResultPropertyType(org.isotc211.x2005.gmd.DQResultPropertyType) CIDateType(org.isotc211.x2005.gmd.CIDateType) CIContactType(org.isotc211.x2005.gmd.CIContactType) ShowType(org.w3.x1999.xlink.ShowType) MDIdentificationPropertyType(org.isotc211.x2005.gmd.MDIdentificationPropertyType) EXExtentType(org.isotc211.x2005.gmd.EXExtentType) CIOnlineResourcePropertyType(org.isotc211.x2005.gmd.CIOnlineResourcePropertyType) BaseUnitType(net.opengis.gml.x32.BaseUnitType) CITelephonePropertyType(org.isotc211.x2005.gmd.CITelephonePropertyType) ActuateType(org.w3.x1999.xlink.ActuateType) CIAddressPropertyType(org.isotc211.x2005.gmd.CIAddressPropertyType) UnitOfMeasurePropertyType(org.isotc211.x2005.gco.UnitOfMeasurePropertyType) EXVerticalExtentPropertyType(org.isotc211.x2005.gmd.EXVerticalExtentPropertyType) CIOnlineResourceType(org.isotc211.x2005.gmd.CIOnlineResourceType) DQQuantitativeResultType(org.isotc211.x2005.gmd.DQQuantitativeResultType) CIResponsiblePartyType(org.isotc211.x2005.gmd.CIResponsiblePartyType) SupportedType(org.n52.shetland.ogc.SupportedType) LocalisedCharacterStringType(org.isotc211.x2005.gmd.LocalisedCharacterStringType) CICitationPropertyType(org.isotc211.x2005.gmd.CICitationPropertyType) CITelephoneType(org.isotc211.x2005.gmd.CITelephoneType) DQConformanceResultType(org.isotc211.x2005.gmd.DQConformanceResultType) TypeType(org.w3.x1999.xlink.TypeType) Type(org.n52.shetland.w3c.xlink.Type) CIRoleCodePropertyType(org.isotc211.x2005.gmd.CIRoleCodePropertyType) MDDataIdentificationPropertyType(org.isotc211.x2005.gmd.MDDataIdentificationPropertyType) RealPropertyType(org.isotc211.x2005.gco.RealPropertyType) AbstractMDIdentificationType(org.isotc211.x2005.gmd.AbstractMDIdentificationType) PTFreeTextType(org.isotc211.x2005.gmd.PTFreeTextType) SCCRSPropertyType(org.isotc211.x2005.gsr.SCCRSPropertyType) CIResponsiblePartyPropertyType(org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType) Reference(org.n52.shetland.w3c.xlink.Reference) Show(org.n52.shetland.w3c.xlink.Show) CiAddress(org.n52.shetland.iso.gmd.CiAddress) CIAddressType(org.isotc211.x2005.gmd.CIAddressType) TypeType(org.w3.x1999.xlink.TypeType) ShowType(org.w3.x1999.xlink.ShowType)

Example 58 with If

use of org.w3._2007.rif.If in project arctic-sea by 52North.

the class Soap12Decoder method createEnvelope.

/**
 * Parses SOAP 1.2 Envelope to a SOS internal SOAP request.
 *
 * @param doc
 *            request as xml representation
 *
 * @return SOS internal SOAP request
 *
 * @throws DecodingException
 *             if an error occurs.
 */
@Override
protected SoapRequest createEnvelope(XmlObject doc) throws DecodingException {
    SoapRequest soapRequest = new SoapRequest(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, SOAPConstants.SOAP_1_2_PROTOCOL);
    String soapAction = "";
    try {
        SOAPMessage message;
        try {
            message = SoapHelper.getSoapMessageForProtocol(SOAPConstants.SOAP_1_2_PROTOCOL, doc.newInputStream());
        } catch (IOException | SOAPException ioe) {
            throw new NoApplicableCodeException().causedBy(ioe).withMessage("Error while parsing SOAPMessage from request string!");
        }
        try {
            if (message.getSOAPHeader() != null) {
                soapRequest.setSoapHeader(getSoapHeader(message.getSOAPHeader()));
            }
            soapRequest.setAction(checkSoapAction(soapAction, soapRequest.getSoapHeader()));
            soapRequest.setSoapBodyContent(getBodyContent((EnvelopeDocument) doc));
        } catch (SOAPException soape) {
            throw new NoApplicableCodeException().causedBy(soape).withMessage("Error while parsing SOAPMessage!");
        }
    } catch (OwsExceptionReport owse) {
        throw new DecodingException(owse);
    }
    return soapRequest;
}
Also used : SoapRequest(org.n52.shetland.w3c.soap.SoapRequest) EnvelopeDocument(org.w3.x2003.x05.soapEnvelope.EnvelopeDocument) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) SOAPException(javax.xml.soap.SOAPException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) IOException(java.io.IOException) SOAPMessage(javax.xml.soap.SOAPMessage) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport)

Example 59 with If

use of org.w3._2007.rif.If in project arctic-sea by 52North.

the class Soap12Encoder method createSOAP12Fault.

private XmlObject createSOAP12Fault(final SoapFault soapFault) {
    final FaultDocument faultDoc = FaultDocument.Factory.newInstance();
    final Fault fault = faultDoc.addNewFault();
    fault.addNewCode().setValue(soapFault.getFaultCode());
    final Reasontext addNewText = fault.addNewReason().addNewText();
    addNewText.setLang(soapFault.getLocale().getDisplayLanguage());
    addNewText.setStringValue(soapFault.getFaultReason());
    if (soapFault.getDetailText() != null) {
        final XmlString xmlString = XmlString.Factory.newInstance();
        xmlString.setStringValue(soapFault.getDetailText());
        fault.addNewDetail().set(xmlString);
    }
    return faultDoc;
}
Also used : FaultDocument(org.w3.x2003.x05.soapEnvelope.FaultDocument) Reasontext(org.w3.x2003.x05.soapEnvelope.Reasontext) XmlString(org.apache.xmlbeans.XmlString) SoapFault(org.n52.shetland.w3c.soap.SoapFault) Fault(org.w3.x2003.x05.soapEnvelope.Fault)

Example 60 with If

use of org.w3._2007.rif.If 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)

Aggregations

Actuate (org.n52.shetland.w3c.xlink.Actuate)15 Show (org.n52.shetland.w3c.xlink.Show)15 ActuateType (org.w3.x1999.xlink.ActuateType)15 ShowType (org.w3.x1999.xlink.ShowType)15 Reference (org.n52.shetland.w3c.xlink.Reference)14 Type (org.n52.shetland.w3c.xlink.Type)14 TypeType (org.w3.x1999.xlink.TypeType)14 IOException (java.io.IOException)13 XmlObject (org.apache.xmlbeans.XmlObject)11 AbstractCRSType (net.opengis.gml.x32.AbstractCRSType)10 CodeType (net.opengis.gml.x32.CodeType)10 EXExtentType (org.isotc211.x2005.gmd.EXExtentType)10 ProvideAndRegisterDocumentSetRequestType (ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType)9 ArrayList (java.util.ArrayList)8 CIResponsiblePartyPropertyType (org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType)8 CIResponsiblePartyType (org.isotc211.x2005.gmd.CIResponsiblePartyType)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 BaseUnitType (net.opengis.gml.x32.BaseUnitType)6 VerticalDatumPropertyType (net.opengis.gml.x32.VerticalDatumPropertyType)5 VerticalDatumType (net.opengis.gml.x32.VerticalDatumType)5