use of net.opengis.cat.csw.v_2_0_2.CapabilitiesType in project ddf by codice.
the class TestCswSourceBase method createMockCsw.
protected Csw createMockCsw() throws CswException {
Csw mockCsw = mock(Csw.class);
InputStream stream = getClass().getResourceAsStream("/getCapabilities.xml");
CapabilitiesType capabilities = parseXml(stream);
when(mockCsw.getCapabilities(any(GetCapabilitiesRequest.class))).thenReturn(capabilities);
CswRecordCollection collection = generateCswCollection("/getBriefRecordsResponse.xml");
when(mockCsw.getRecords(any(GetRecordsType.class))).thenReturn(collection);
return mockCsw;
}
use of net.opengis.cat.csw.v_2_0_2.CapabilitiesType in project ddf by codice.
the class TestCswSource method testCswSourceNoFilterCapabilities.
@Test(expected = UnsupportedQueryException.class)
public void testCswSourceNoFilterCapabilities() throws CswException, UnsupportedQueryException, SecurityServiceException {
// Setup
CapabilitiesType mockCapabilitiesType = mock(CapabilitiesType.class);
when(mockCsw.getCapabilities(any(GetCapabilitiesRequest.class))).thenReturn(mockCapabilitiesType);
AbstractCswSource cswSource = getCswSource(mockCsw, mockContext);
cswSource.setCswUrl(URL);
cswSource.setId(ID);
QueryImpl propertyIsLikeQuery = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text("junk"));
propertyIsLikeQuery.setPageSize(10);
cswSource.query(new QueryRequestImpl(propertyIsLikeQuery));
}
use of net.opengis.cat.csw.v_2_0_2.CapabilitiesType in project ddf by codice.
the class CswEndpoint method buildCapabilitiesType.
/**
* Creates a full CapabilitiesType element to be returned as the GetCapabilities response
*
* @return The constructed CapabilitiesType object
*/
private CapabilitiesType buildCapabilitiesType() {
if (capabilitiesType == null) {
CapabilitiesType cswCapabilities = new CapabilitiesType();
cswCapabilities.setVersion(CswConstants.VERSION_2_0_2);
cswCapabilities.setServiceIdentification(buildServiceIdentification());
cswCapabilities.setServiceProvider(buildServiceProvider());
cswCapabilities.setOperationsMetadata(buildOperationsMetadata());
cswCapabilities.setFilterCapabilities(buildFilterCapabilities());
return cswCapabilities;
} else {
capabilitiesType.setOperationsMetadata(buildOperationsMetadata());
return capabilitiesType;
}
}
use of net.opengis.cat.csw.v_2_0_2.CapabilitiesType in project ddf by codice.
the class CswEndpoint method buildCapabilitiesType.
/**
* Creates a CapabilitiesType object with only specified sections to be returned as a
* GetCapabilities response.
*
* @param sections The list of desired sections for the GetCapabilities response
* @return The constructed CapabilitiesType object, containing only the user-specified sections
*/
private CapabilitiesType buildCapabilitiesType(List<String> sections) {
// If no sections are specified, return them all
if (sections == null || sections.size() == 0) {
return capabilitiesType;
}
CapabilitiesType cswCapabilities = new CapabilitiesType();
cswCapabilities.setVersion(capabilitiesType.getVersion());
// Grab the desired sections from the global capabilitiesType variable
for (String section : sections) {
if (section.equalsIgnoreCase(SERVICE_IDENTIFICATION)) {
cswCapabilities.setServiceIdentification(capabilitiesType.getServiceIdentification());
} else if (section.equalsIgnoreCase(SERVICE_PROVIDER)) {
cswCapabilities.setServiceProvider(capabilitiesType.getServiceProvider());
} else if (section.equalsIgnoreCase(OPERATIONS_METADATA)) {
cswCapabilities.setOperationsMetadata(capabilitiesType.getOperationsMetadata());
}
}
// filterCapabilities is required. Add it even if it isn't in the sections list.
cswCapabilities.setFilterCapabilities(capabilitiesType.getFilterCapabilities());
return cswCapabilities;
}
use of net.opengis.cat.csw.v_2_0_2.CapabilitiesType in project ddf by codice.
the class TestCswEndpoint method testCapabilitiesRequestServiceProvider.
@Test
public void testCapabilitiesRequestServiceProvider() {
// Should only return the ServiceProvider section
GetCapabilitiesRequest gcr = createDefaultGetCapabilitiesRequest();
gcr.setSections(CswEndpoint.SERVICE_PROVIDER);
CapabilitiesType ct = null;
try {
ct = csw.getCapabilities(gcr);
} catch (CswException e) {
fail("CswException caught during getCapabilities GET request: " + e.getMessage());
}
assertThat(ct, notNullValue());
assertThat(ct.getOperationsMetadata(), nullValue());
assertThat(ct.getServiceIdentification(), nullValue());
verifyFilterCapabilities(ct);
verifyServiceProvider(ct);
}
Aggregations