use of org.apache.type_test.types3.ObjectFactory in project ddf by codice.
the class AbstractCswSource method createSubscriptionGetRecordsRequest.
private GetRecordsType createSubscriptionGetRecordsRequest() {
GetRecordsType getRecordsType = new GetRecordsType();
getRecordsType.setVersion(cswVersion);
getRecordsType.setService(CswConstants.CSW);
getRecordsType.setResultType(ResultType.RESULTS);
getRecordsType.setStartPosition(BigInteger.ONE);
getRecordsType.setMaxRecords(BigInteger.TEN);
getRecordsType.setOutputFormat(MediaType.APPLICATION_XML);
getRecordsType.setOutputSchema("urn:catalog:metacard");
getRecordsType.getResponseHandler().add(SystemBaseUrl.EXTERNAL.constructUrl("csw/subscription/event", true));
QueryType queryType = new QueryType();
queryType.setElementSetName(createElementSetName(ElementSetType.FULL));
ObjectFactory objectFactory = new ObjectFactory();
getRecordsType.setAbstractQuery(objectFactory.createQuery(queryType));
return getRecordsType;
}
use of org.apache.type_test.types3.ObjectFactory in project ddf by codice.
the class CswSubscriptionEndpointTest method testCreateOrUpdateSubscriptionPersitanceFalse.
@Test
public void testCreateOrUpdateSubscriptionPersitanceFalse() throws Exception {
ObjectFactory objectFactory = new ObjectFactory();
GetRecordsType getRecordsType = createDefaultGetRecordsRequest().get202RecordsType();
QueryType queryType = new QueryType();
getRecordsType.setAbstractQuery(objectFactory.createQuery(queryType));
cswSubscriptionEndpoint.createOrUpdateSubscription(getRecordsType, subscriptionId, false);
verify(mockContext).registerService(eq(Subscription.class.getName()), any(Subscription.class), any(Dictionary.class));
}
use of org.apache.type_test.types3.ObjectFactory in project ddf by codice.
the class SendEventTest method setUp.
@Before
public void setUp() throws Exception {
System.setProperty("ddf.home", ".");
callbackURI = new URL("https://localhost:12345/services/csw/subscription/event");
ObjectFactory objectFactory = new ObjectFactory();
request = new GetRecordsType();
request.setOutputSchema(CswConstants.CSW_OUTPUT_SCHEMA);
request.setResultType(ResultType.RESULTS);
request.getResponseHandler().add(callbackURI.toString());
queryType = new QueryType();
elementSetNameType = new ElementSetNameType();
elementSetNameType.setValue(ElementSetType.BRIEF);
queryType.setElementSetName(elementSetNameType);
request.setAbstractQuery(objectFactory.createAbstractQuery(queryType));
transformerManager = mock(TransformerManager.class);
transformer = mock(QueryResponseTransformer.class);
binaryContent = mock(BinaryContent.class);
when(transformerManager.getTransformerBySchema(ArgumentMatchers.contains(CswConstants.CSW_OUTPUT_SCHEMA))).thenReturn(transformer);
when(transformer.transform(any(SourceResponse.class), anyMap())).thenReturn(binaryContent);
when(binaryContent.getByteArray()).thenReturn("byte array with message contents".getBytes());
query = mock(QueryRequest.class);
metacard = mock(Metacard.class);
webclient = mock(WebClient.class);
mockCxfClientFactory = mock(SecureCxfClientFactory.class);
response = mock(Response.class);
subject = mock(Subject.class);
mockSecurity = mock(Security.class);
headers.put(Subject.class.toString(), Arrays.asList(new Subject[] { subject }));
AccessPlugin accessPlugin = mock(AccessPlugin.class);
accessPlugins.add(accessPlugin);
when(mockCxfClientFactory.getWebClient()).thenReturn(webclient);
when(webclient.invoke(anyString(), isNull())).thenReturn(response);
when(response.getHeaders()).thenReturn(headers);
when(accessPlugin.processPostQuery(any(QueryResponse.class))).thenAnswer(invocationOnMock -> invocationOnMock.getArguments()[0]);
sendEvent = new SendEventExtension(request, query, mockCxfClientFactory);
sendEvent.setSubject(subject);
}
use of org.apache.type_test.types3.ObjectFactory in project ddf by codice.
the class CswQueryFactoryTest method setUp.
@org.junit.Before
public void setUp() throws URISyntaxException, SourceUnavailableException, UnsupportedQueryException, FederationException, ParseException, IngestException {
FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
FilterAdapter filterAdapter = new GeotoolsFilterAdapterImpl();
CswRecordMap cswRecordMap = new MetacardCswRecordMap();
queryFactory = new CswQueryFactory(cswRecordMap, filterBuilder, filterAdapter, new PermissionsImpl());
AttributeRegistryImpl attributeRegistry = new AttributeRegistryImpl();
attributeRegistry.registerMetacardType(getCswMetacardType());
queryFactory.setAttributeRegistry(attributeRegistry);
polygon = new WKTReader().read(POLYGON_STR);
gmlObjectFactory = new net.opengis.gml.v_3_1_1.ObjectFactory();
filterObjectFactory = new ObjectFactory();
queryFilterTransformerProvider = mock(QueryFilterTransformerProvider.class);
QueryFilterTransformer cswQueryFilter = new CswQueryFilterTransformer(new MetacardCswRecordMap(), attributeRegistry);
when(queryFilterTransformerProvider.getTransformer(new QName(CswConstants.CSW_OUTPUT_SCHEMA, "Record"))).thenReturn(Optional.of(cswQueryFilter));
when(queryFilterTransformerProvider.getTransformer(anyString())).thenReturn(Optional.of(cswQueryFilter));
queryFactory.setQueryFilterTransformerProvider(queryFilterTransformerProvider);
}
use of org.apache.type_test.types3.ObjectFactory 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", e);
}
JAXBElement<AcknowledgementType> jaxBAck = new ObjectFactory().createAcknowledgement(ack);
marshaller.marshal(jaxBAck, byteArrayOutputStream);
return byteArrayOutputStream;
} catch (JAXBException e) {
throw new CatalogTransformerException(e);
}
}
Aggregations