Search in sources :

Example 26 with CswTransactionRequest

use of org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest 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 27 with CswTransactionRequest

use of org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest in project ddf by codice.

the class TestCswEndpoint method testIngestTransaction.

@Test
public void testIngestTransaction() throws CswException, SourceUnavailableException, FederationException, IngestException {
    CswTransactionRequest request = new CswTransactionRequest();
    request.getInsertActions().add(new InsertAction(CswConstants.CSW_TYPE, null, Arrays.asList(new MetacardImpl())));
    TransactionResponseType response = csw.transaction(request);
    assertThat(response, notNullValue());
    assertThat(response.getInsertResult().isEmpty(), is(true));
    assertThat(response.getTransactionSummary(), notNullValue());
    TransactionSummaryType summary = response.getTransactionSummary();
    assertThat(summary.getTotalDeleted().intValue(), is(0));
    assertThat(summary.getTotalUpdated().intValue(), is(0));
    assertThat(summary.getTotalInserted().intValue(), is(1));
    verifyMarshalResponse(response, "net.opengis.cat.csw.v_2_0_2:net.opengis.filter.v_1_1_0:net.opengis.gml.v_3_1_1", cswQnameOutPutSchema);
}
Also used : CswTransactionRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest) InsertAction(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.InsertAction) TransactionSummaryType(net.opengis.cat.csw.v_2_0_2.TransactionSummaryType) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) TransactionResponseType(net.opengis.cat.csw.v_2_0_2.TransactionResponseType) Test(org.junit.Test)

Aggregations

CswTransactionRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest)27 Test (org.junit.Test)20 UpdateAction (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.UpdateAction)14 DeleteAction (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.DeleteAction)13 InsertAction (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.InsertAction)13 Metacard (ddf.catalog.data.Metacard)10 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)10 TransactionResponseType (net.opengis.cat.csw.v_2_0_2.TransactionResponseType)8 ArrayList (java.util.ArrayList)7 QueryConstraintType (net.opengis.cat.csw.v_2_0_2.QueryConstraintType)7 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)7 Serializable (java.io.Serializable)6 CswRecordConverter (org.codice.ddf.spatial.ogc.csw.catalog.converter.CswRecordConverter)6 Converter (com.thoughtworks.xstream.converters.Converter)5 DeleteType (net.opengis.cat.csw.v_2_0_2.DeleteType)5 TransactionSummaryType (net.opengis.cat.csw.v_2_0_2.TransactionSummaryType)5 HashMap (java.util.HashMap)4 UpdateResponseImpl (ddf.catalog.operation.impl.UpdateResponseImpl)3 IngestException (ddf.catalog.source.IngestException)3 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)3