use of net.opengis.cat.csw.v_2_0_2.AcknowledgementType 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);
}
}
use of net.opengis.cat.csw.v_2_0_2.AcknowledgementType 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();
}
use of net.opengis.cat.csw.v_2_0_2.AcknowledgementType in project ddf by codice.
the class TestCswSource method testRefreshWithUpdateRegisterForEvents.
@Test
public void testRefreshWithUpdateRegisterForEvents() throws Exception {
String subscriptionId = "subscriptionid";
String eventEndpoint = "https://ddf/services/csw/subscriptions";
CswSourceStub cswSource = (CswSourceStub) getCswSource(mockCsw, mockContext, "contentType");
cswSource.filterlessSubscriptionId = subscriptionId;
CswSubscribe client = mock(CswSubscribe.class);
Response response = mock(Response.class);
AcknowledgementType ack = mock(AcknowledgementType.class);
when(client.createRecordsSubscription(any(GetRecordsType.class))).thenReturn(response);
when(response.getStatus()).thenReturn(200);
when(response.readEntity(any(Class.class))).thenReturn(ack);
when(ack.getRequestId()).thenReturn(subscriptionId);
when(cswSource.getSubscriberClientFactory().getClientForSubject(cswSource.getSubject())).thenReturn(client);
cswSource.cswSourceConfiguration.setRegisterForEvents(true);
cswSource.cswSourceConfiguration.setEventServiceAddress(eventEndpoint + "/original");
// Set Configuration Map
Map<String, Object> configuration = getConfigurationMap(cswSource);
configuration.put(cswSource.REGISTER_FOR_EVENTS, true);
configuration.put(cswSource.EVENT_SERVICE_ADDRESS, eventEndpoint);
// Call Refresh
cswSource.refresh(configuration);
// Get Configuration
CswSourceConfiguration cswSourceConfiguration = cswSource.cswSourceConfiguration;
// Assert Refresh Changes
Assert.assertTrue(cswSourceConfiguration.isRegisterForEvents());
Assert.assertEquals(cswSourceConfiguration.getEventServiceAddress(), eventEndpoint);
verify(client).deleteRecordsSubscription(subscriptionId);
verify(ack).getRequestId();
}
use of net.opengis.cat.csw.v_2_0_2.AcknowledgementType in project ddf by codice.
the class TestCswSource method testRefreshWithUnregisterForEvents.
@Test
public void testRefreshWithUnregisterForEvents() throws Exception {
String subscriptionId = "subscriptionid";
String eventEndpoint = "https://ddf/services/csw/subscriptions";
CswSourceStub cswSource = (CswSourceStub) getCswSource(mockCsw, mockContext, "contentType");
cswSource.filterlessSubscriptionId = subscriptionId;
CswSubscribe client = mock(CswSubscribe.class);
Response response = mock(Response.class);
AcknowledgementType ack = mock(AcknowledgementType.class);
when(client.createRecordsSubscription(any(GetRecordsType.class))).thenReturn(response);
when(response.getStatus()).thenReturn(200);
when(response.readEntity(any(Class.class))).thenReturn(ack);
when(ack.getRequestId()).thenReturn(subscriptionId);
when(cswSource.getSubscriberClientFactory().getClientForSubject(cswSource.getSubject())).thenReturn(client);
cswSource.cswSourceConfiguration.setRegisterForEvents(true);
cswSource.cswSourceConfiguration.setEventServiceAddress(eventEndpoint);
// Set Configuration Map
Map<String, Object> configuration = getConfigurationMap(cswSource);
configuration.put(cswSource.REGISTER_FOR_EVENTS, false);
configuration.put(cswSource.EVENT_SERVICE_ADDRESS, eventEndpoint);
// Call Refresh
cswSource.refresh(configuration);
// Get Configuration
CswSourceConfiguration cswSourceConfiguration = cswSource.cswSourceConfiguration;
// Assert Refresh Changes
Assert.assertFalse(cswSourceConfiguration.isRegisterForEvents());
Assert.assertEquals(cswSourceConfiguration.getEventServiceAddress(), eventEndpoint);
verify(client).deleteRecordsSubscription(subscriptionId);
}
use of net.opengis.cat.csw.v_2_0_2.AcknowledgementType in project ddf by codice.
the class CswSubscriptionEndpointTest method testCreateRecordsSubscriptionPOST.
@Test
public void testCreateRecordsSubscriptionPOST() throws Exception {
CSW_LOGGER.setLevel(Level.DEBUG);
GetRecordsRequest getRecordsRequest = createDefaultGetRecordsRequest();
getRecordsRequest.setResponseHandler(RESPONSE_HANDLER_URL);
Response response = cswSubscriptionEndpoint.createRecordsSubscription(getRecordsRequest.get202RecordsType());
AcknowledgementType createAck = (AcknowledgementType) response.getEntity();
assertThat(createAck, notNullValue());
assertThat(createAck.getRequestId(), notNullValue());
CSW_LOGGER.setLevel(Level.INFO);
verify(mockContext).registerService(eq(Subscription.class.getName()), any(Subscription.class), any(Dictionary.class));
}
Aggregations