if (request.getSections() != null) {
sections = request.getSections();
}
// encode the response
CapabilitiesType caps = cswf.createCapabilitiesType();
caps.setVersion(CSW_VERSION);
// ServiceIdentification
if (sections == null || requestedSection("ServiceIdentification", sections)) {
ServiceIdentificationType si = owsf.createServiceIdentificationType();
caps.setServiceIdentification(si);
si.setTitle(csw.getTitle());
si.setAbstract(csw.getAbstract());
KeywordsType kw = null;
List<KeywordInfo> keywords = csw.getKeywords();
if (keywords != null && keywords.size() > 0) {
kw = owsf.createKeywordsType();
for (KeywordInfo keyword : keywords) {
kw.getKeyword().add(keyword.getValue());
}
}
if (kw != null) {
si.getKeywords().add(kw);
}
CodeType CSW = owsf.createCodeType();
CSW.setValue("CSW");
si.setServiceType(CSW);
si.setServiceTypeVersion(CSW_VERSION);
si.setFees(csw.getFees());
if (csw.getAccessConstraints() != null) {
si.setAccessConstraints(csw.getAccessConstraints());
}
}
// ServiceProvider
if (sections == null || requestedSection("ServiceProvider", sections)) {
ServiceProviderType sp = owsf.createServiceProviderType();
caps.setServiceProvider(sp);
final ContactInfo contact = csw.getGeoServer().getGlobal().getSettings().getContact();
sp.setProviderName((contact.getContactOrganization() != null ? contact.getContactOrganization() : ""));
OnlineResourceType providerSite = owsf.createOnlineResourceType();
sp.setProviderSite(providerSite);
providerSite.setHref((csw.getOnlineResource() != null ? csw.getOnlineResource() : ""));
ResponsiblePartySubsetType serviceContact = owsf.createResponsiblePartySubsetType();
sp.setServiceContact(serviceContact);
serviceContact.setIndividualName(contact.getContactPerson());
serviceContact.setPositionName(contact.getContactPosition());
ContactType contactInfo = owsf.createContactType();
serviceContact.setContactInfo(contactInfo);
AddressType address = owsf.createAddressType();
contactInfo.setAddress(address);
address.setAdministrativeArea(contact.getAddressState());
address.setCity(contact.getAddressCity());
address.setCountry(contact.getAddressCountry());
address.setDeliveryPoint(null);
address.setElectronicMailAddress(contact.getContactEmail());
address.setPostalCode(contact.getAddressPostalCode());
contactInfo.setContactInstructions(null);
contactInfo.setHoursOfService(null);
OnlineResourceType onlineResource = owsf.createOnlineResourceType();
contactInfo.setOnlineResource(onlineResource);
onlineResource.setHref(contact.getOnlineResource());
TelephoneType telephone = owsf.createTelephoneType();
contactInfo.setPhone(telephone);
telephone.setFacsimile(contact.getContactFacsimile());
telephone.setVoice(contact.getContactVoice());
serviceContact.setRole(null);
}
// Operations Metadata
if (sections == null || requestedSection("OperationsMetadata", sections)) {
final String baseUrl = (String) EMFUtils.get(request, "baseUrl");
if (baseUrl == null) {
throw new IllegalArgumentException("Request object" + request
+ " has no 'baseUrl' property.");
}
OperationsMetadataType operationsMetadata = owsf.createOperationsMetadataType();
caps.setOperationsMetadata(operationsMetadata);
OperationMetadata_GetCapabilities(owsf, baseUrl, operationsMetadata);
OperationMetadata_DescribeRecord(owsf, baseUrl, operationsMetadata);
OperationMetadata_GetDomain(owsf, baseUrl, operationsMetadata);
OperationMetadata_GetRecords(owsf, baseUrl, operationsMetadata);
OperationMetadata_GetRecordById(owsf, baseUrl, operationsMetadata);
if (store.getCapabilities().supportsTransactions()) {
OperationMetadata_Transaction(owsf, baseUrl, operationsMetadata);
}
// - Parameters
for (DomainType param : operationParameters.get("OperationsMetadata"))
{
// clone the object, as the caps decorators might want to modify it
operationsMetadata.getParameter().add(EcoreUtil.copy(param));
}
// - Constraints
for (DomainType constraint : operationConstraints.get("OperationsMetadata"))
{
// clone the object, as the caps decorators might want to modify it
operationsMetadata.getConstraint().add(EcoreUtil.copy(constraint));
}
}
// Filter Capabilities
// this part is not optional, the schema has min = 0, so we don't check for the sections
final FilterFactory2 ffFactory = CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints());
// - Spatial Capabilities
//SpatialCapabilities spatialCapabilities = ffFactory.spatialCapabilities(geometryOperands, spatialOperands);
SpatialCapabilities spatialCapabilities = new CSWSpatialCapabilities();
// - Scalar Capabilities
Operator[] operators = new Operator[] { ffFactory.operator("EqualTo"),
ffFactory.operator("Like"), ffFactory.operator("LessThan"),
ffFactory.operator("GreaterThan"), ffFactory.operator("LessThanEqualTo"),
ffFactory.operator("GreaterThanEqualTo"), ffFactory.operator("NotEqualTo"),
ffFactory.operator("Between"), ffFactory.operator("NullCheck") };
ComparisonOperators comparisonOperators = ffFactory.comparisonOperators(operators);
ArithmeticOperators arithmeticOperators = ffFactory.arithmeticOperators(true, null);
ScalarCapabilities scalarCapabilities = ffFactory.scalarCapabilities(
comparisonOperators, arithmeticOperators, logicalOperators);
// - removing Arithmetic Operators...
((ScalarCapabilitiesImpl)scalarCapabilities).setArithmeticOperators(null);
// - Id Capabilities
IdCapabilities id = ffFactory.idCapabilities(eid, fid);
FilterCapabilities filterCapabilities = ffFactory.capabilities("1.1.0",
scalarCapabilities, spatialCapabilities, id);
((FilterCapabilitiesImpl)filterCapabilities).setScalar(scalarCapabilities);
((FilterCapabilitiesImpl)filterCapabilities).setSpatial(spatialCapabilities);
((FilterCapabilitiesImpl)filterCapabilities).setId(id);
caps.setFilterCapabilities(filterCapabilities);
return caps;
}