Search in sources :

Example 1 with EchoedRequestType

use of net.opengis.cat.csw.v_2_0_2.EchoedRequestType in project ddf by codice.

the class CswQueryResponseTransformer method writeAcknowledgement.

private ByteArrayOutputStream writeAcknowledgement(GetRecordsType request) throws CatalogTransformerException {
    try {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        JAXBContext jaxBContext = JAXBContext.newInstance("net.opengis.cat.csw.v_2_0_2:" + "net.opengis.filter.v_1_1_0:net.opengis.gml.v_3_1_1:net.opengis.ows.v_1_0_0");
        Marshaller marshaller = jaxBContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        AcknowledgementType ack = new AcknowledgementType();
        EchoedRequestType echoedRequest = new EchoedRequestType();
        JAXBElement<GetRecordsType> jaxBRequest = new ObjectFactory().createGetRecords(request);
        echoedRequest.setAny(jaxBRequest);
        ack.setEchoedRequest(echoedRequest);
        try {
            ack.setTimeStamp(DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar()));
        } catch (DatatypeConfigurationException e) {
            LOGGER.debug("Failed to set timestamp on Acknowledgement, Exception {}", e);
        }
        JAXBElement<AcknowledgementType> jaxBAck = new ObjectFactory().createAcknowledgement(ack);
        marshaller.marshal(jaxBAck, byteArrayOutputStream);
        return byteArrayOutputStream;
    } catch (JAXBException e) {
        throw new CatalogTransformerException(e);
    }
}
Also used : Marshaller(javax.xml.bind.Marshaller) JAXBException(javax.xml.bind.JAXBException) GregorianCalendar(java.util.GregorianCalendar) EchoedRequestType(net.opengis.cat.csw.v_2_0_2.EchoedRequestType) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) JAXBContext(javax.xml.bind.JAXBContext) CatalogTransformerException(ddf.catalog.transform.CatalogTransformerException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) ObjectFactory(net.opengis.cat.csw.v_2_0_2.ObjectFactory) AcknowledgementType(net.opengis.cat.csw.v_2_0_2.AcknowledgementType)

Example 2 with EchoedRequestType

use of net.opengis.cat.csw.v_2_0_2.EchoedRequestType in project ddf by codice.

the class CswSubscriptionEndpoint method createAcknowledgment.

private Response createAcknowledgment(GetRecordsType request) {
    AcknowledgementType acknowledgementType = new AcknowledgementType();
    if (request != null) {
        EchoedRequestType echoedRequest = new EchoedRequestType();
        echoedRequest.setAny(objectFactory.createGetRecords(request));
        acknowledgementType.setEchoedRequest(echoedRequest);
        acknowledgementType.setRequestId(request.getRequestId());
    }
    if (datatypeFactory != null) {
        acknowledgementType.setTimeStamp(datatypeFactory.newXMLGregorianCalendar());
    }
    return Response.ok().entity(acknowledgementType).build();
}
Also used : EchoedRequestType(net.opengis.cat.csw.v_2_0_2.EchoedRequestType) AcknowledgementType(net.opengis.cat.csw.v_2_0_2.AcknowledgementType)

Aggregations

AcknowledgementType (net.opengis.cat.csw.v_2_0_2.AcknowledgementType)2 EchoedRequestType (net.opengis.cat.csw.v_2_0_2.EchoedRequestType)2 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 GregorianCalendar (java.util.GregorianCalendar)1 JAXBContext (javax.xml.bind.JAXBContext)1 JAXBException (javax.xml.bind.JAXBException)1 Marshaller (javax.xml.bind.Marshaller)1 DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)1 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)1 ObjectFactory (net.opengis.cat.csw.v_2_0_2.ObjectFactory)1