Search in sources :

Example 1 with Xpp3Driver

use of com.thoughtworks.xstream.io.xml.Xpp3Driver in project ddf by codice.

the class TransactionMessageBodyReader method readFrom.

@Override
public CswTransactionRequest readFrom(Class<CswTransactionRequest> aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> multivaluedMap, InputStream inputStream) throws IOException, WebApplicationException {
    XStream xStream = new XStream(new Xpp3Driver());
    TransactionRequestConverter transactionRequestConverter = new TransactionRequestConverter(cswRecordConverter, registry);
    transactionRequestConverter.setCswRecordConverter(new CswRecordConverter(metacardType));
    xStream.registerConverter(transactionRequestConverter);
    xStream.alias("csw:" + CswConstants.TRANSACTION, CswTransactionRequest.class);
    xStream.alias(CswConstants.TRANSACTION, CswTransactionRequest.class);
    return (CswTransactionRequest) xStream.fromXML(inputStream);
}
Also used : Xpp3Driver(com.thoughtworks.xstream.io.xml.Xpp3Driver) TransactionRequestConverter(org.codice.ddf.spatial.ogc.csw.catalog.converter.TransactionRequestConverter) XStream(com.thoughtworks.xstream.XStream) CswTransactionRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest) CswRecordConverter(org.codice.ddf.spatial.ogc.csw.catalog.converter.CswRecordConverter)

Example 2 with Xpp3Driver

use of com.thoughtworks.xstream.io.xml.Xpp3Driver in project ddf by codice.

the class TestTransactionRequestConverter method setup.

@Before
public void setup() {
    cswRecordConverter = mock(Converter.class);
    when(cswRecordConverter.canConvert(any())).thenReturn(true);
    new CoreAttributes().getAttributeDescriptors().stream().forEach(d -> mockRegistry.register(d));
    new ContactAttributes().getAttributeDescriptors().stream().forEach(d -> mockRegistry.register(d));
    new LocationAttributes().getAttributeDescriptors().stream().forEach(d -> mockRegistry.register(d));
    new MediaAttributes().getAttributeDescriptors().stream().forEach(d -> mockRegistry.register(d));
    new TopicAttributes().getAttributeDescriptors().stream().forEach(d -> mockRegistry.register(d));
    new AssociationsAttributes().getAttributeDescriptors().stream().forEach(d -> mockRegistry.register(d));
    xStream = new XStream(new Xpp3Driver());
    xStream.registerConverter(new TransactionRequestConverter(cswRecordConverter, mockRegistry));
    xStream.alias(CswConstants.CSW_TRANSACTION, CswTransactionRequest.class);
}
Also used : Xpp3Driver(com.thoughtworks.xstream.io.xml.Xpp3Driver) ContactAttributes(ddf.catalog.data.impl.types.ContactAttributes) LocationAttributes(ddf.catalog.data.impl.types.LocationAttributes) XStream(com.thoughtworks.xstream.XStream) CoreAttributes(ddf.catalog.data.impl.types.CoreAttributes) AssociationsAttributes(ddf.catalog.data.impl.types.AssociationsAttributes) Converter(com.thoughtworks.xstream.converters.Converter) MediaAttributes(ddf.catalog.data.impl.types.MediaAttributes) TopicAttributes(ddf.catalog.data.impl.types.TopicAttributes) Before(org.junit.Before)

Aggregations

XStream (com.thoughtworks.xstream.XStream)2 Xpp3Driver (com.thoughtworks.xstream.io.xml.Xpp3Driver)2 Converter (com.thoughtworks.xstream.converters.Converter)1 AssociationsAttributes (ddf.catalog.data.impl.types.AssociationsAttributes)1 ContactAttributes (ddf.catalog.data.impl.types.ContactAttributes)1 CoreAttributes (ddf.catalog.data.impl.types.CoreAttributes)1 LocationAttributes (ddf.catalog.data.impl.types.LocationAttributes)1 MediaAttributes (ddf.catalog.data.impl.types.MediaAttributes)1 TopicAttributes (ddf.catalog.data.impl.types.TopicAttributes)1 CswTransactionRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest)1 CswRecordConverter (org.codice.ddf.spatial.ogc.csw.catalog.converter.CswRecordConverter)1 TransactionRequestConverter (org.codice.ddf.spatial.ogc.csw.catalog.converter.TransactionRequestConverter)1 Before (org.junit.Before)1