use of org.n52.shetland.ogc.ows.service.GetCapabilitiesResponse in project arctic-sea by 52North.
the class AbstractGetCapabilitiesHandler method handle.
@Override
public GetCapabilitiesResponse handle(GetCapabilitiesRequest request) throws OwsExceptionReport {
String service = request.getService();
String version = negotiateVersion(request);
GetCapabilitiesResponse response = createResponse(service, version);
response.setCapabilities(createCapabilities(request, service, version));
return response;
}
use of org.n52.shetland.ogc.ows.service.GetCapabilitiesResponse in project arctic-sea by 52North.
the class GetCapabilitiesResponseEncoder method encodeResponse.
@Override
protected void encodeResponse(ObjectNode json, GetCapabilitiesResponse t) throws EncodingException {
SosCapabilities caps = (SosCapabilities) t.getCapabilities();
encodeOptional(json, JSONConstants.UPDATE_SEQUENCE, caps.getUpdateSequence(), nodeFactory()::textNode);
encodeOptional(json, JSONConstants.SERVICE_IDENTIFICATION, caps.getServiceIdentification(), this::encodeServiceIdentification);
encodeOptional(json, JSONConstants.SERVICE_PROVIDER, caps.getServiceProvider(), this::encodeServiceProvider);
encodeOptional(json, JSONConstants.OPERATION_METADATA, caps.getOperationsMetadata(), this::encodeOperationMetadata);
encodeOptionalChecked(json, JSONConstants.CONTENTS, caps.getContents(), this::encodeContents);
encodeExtensions(json, caps);
encodeOptional(json, JSONConstants.FILTER_CAPABILITIES, caps.getFilterCapabilities(), this::encodeFilterCapabilities);
}
use of org.n52.shetland.ogc.ows.service.GetCapabilitiesResponse in project arctic-sea by 52North.
the class CapabilitiesV1DocumentDecoder method decode.
@Override
@SuppressFBWarnings("NP_LOAD_OF_KNOWN_NULL_VALUE")
public GetCapabilitiesResponse decode(CapabilitiesDocument cd) throws DecodingException {
if (cd != null) {
GetCapabilitiesResponse response = new GetCapabilitiesResponse();
OwsCapabilities capabilities = (OwsCapabilities) decodeXmlObject(cd.getCapabilities());
response.setCapabilities(capabilities);
return response;
}
throw new UnsupportedDecoderInputException(this, cd);
}
use of org.n52.shetland.ogc.ows.service.GetCapabilitiesResponse in project arctic-sea by 52North.
the class GetCapabilitiesResponseEncoder method create.
@Override
protected XmlObject create(GetCapabilitiesResponse response) throws EncodingException {
CapabilitiesDocument doc = CapabilitiesDocument.Factory.newInstance(getXmlOptions());
CapabilitiesType xbCaps = doc.addNewCapabilities();
if (response.isStatic()) {
String xml = response.getXmlString();
LOGGER.trace("Response is static. XML-String:\n{}\n", xml);
try {
doc.set(XmlObject.Factory.parse(xml));
return doc;
} catch (XmlException ex) {
throw new EncodingException("Error encoding static capabilities", ex);
}
}
// set version.
if (response.getCapabilities().getVersion() != null) {
xbCaps.setVersion(response.getCapabilities().getVersion());
} else {
xbCaps.setVersion(response.getVersion());
}
encodeServiceIdentification(response.getCapabilities(), xbCaps);
encodeServiceProvider(response.getCapabilities(), xbCaps);
encodeOperationsMetadata(response.getCapabilities(), xbCaps);
if (response.getCapabilities() instanceof SosCapabilities) {
SosCapabilities caps = (SosCapabilities) response.getCapabilities();
encodeFilterCapabilities(caps, xbCaps);
encodeContents(caps, xbCaps, response.getVersion());
encodeExtensions(caps, xbCaps);
}
return doc;
}
use of org.n52.shetland.ogc.ows.service.GetCapabilitiesResponse in project arctic-sea by 52North.
the class SosV1GetCapabilitiesResponseEncoder method create.
@Override
protected XmlObject create(GetCapabilitiesResponse response) throws EncodingException {
CapabilitiesDocument xbCapsDoc = CapabilitiesDocument.Factory.newInstance(getXmlOptions());
// cursor for getting prefixes
Capabilities xbCaps = xbCapsDoc.addNewCapabilities();
// set version.
xbCaps.setVersion(response.getVersion());
SosCapabilities sosCapabilities = (SosCapabilities) response.getCapabilities();
if (sosCapabilities.getServiceIdentification().isPresent()) {
xbCaps.addNewServiceIdentification().set(encodeObjectToXml(OWSConstants.NS_OWS, sosCapabilities.getServiceIdentification().get()));
}
if (sosCapabilities.getServiceProvider().isPresent()) {
xbCaps.addNewServiceProvider().set(encodeObjectToXml(OWSConstants.NS_OWS, sosCapabilities.getServiceProvider().get()));
}
if (sosCapabilities.getOperationsMetadata().isPresent()) {
xbCaps.addNewOperationsMetadata().set(encodeObjectToXml(OWSConstants.NS_OWS, sosCapabilities.getOperationsMetadata().get()));
}
if (sosCapabilities.getFilterCapabilities().isPresent()) {
setFilterCapabilities(xbCaps.addNewFilterCapabilities(), sosCapabilities.getFilterCapabilities().get());
}
if (sosCapabilities.getContents().isPresent()) {
setContents(xbCaps.addNewContents(), sosCapabilities.getContents().get(), response.getVersion());
}
N52XmlHelper.setSchemaLocationsToDocument(xbCapsDoc, Sets.newHashSet(N52XmlHelper.getSchemaLocationForSOS100()));
return xbCapsDoc;
}
Aggregations