use of org.n52.shetland.ogc.ows.service.GetCapabilitiesRequest in project arctic-sea by 52North.
the class SimpleBinding method getServiceOperator.
protected ServiceOperator getServiceOperator(OwsServiceRequest request) throws OwsExceptionReport {
checkServiceOperatorKeyTypes(request);
String service = request.getService();
String version = request.getVersion();
if (request instanceof GetCapabilitiesRequest) {
GetCapabilitiesRequest gcr = (GetCapabilitiesRequest) request;
if (gcr.isSetAcceptVersions()) {
return gcr.getAcceptVersions().stream().map(v -> new OwsServiceKey(service, v)).map(this::getServiceOperator).filter(Objects::nonNull).findFirst().orElseThrow(() -> new InvalidServiceOrVersionException(service, version));
} else {
Set<String> supportedVersions = serviceOperatorRepository.getSupportedVersions(service);
String newest = supportedVersions.stream().max(Comparables.version()).orElseThrow(() -> new InvalidServiceParameterException(service));
return getServiceOperator(new OwsServiceKey(service, newest));
}
} else {
return getServiceOperator(new OwsServiceKey(service, version));
}
}
use of org.n52.shetland.ogc.ows.service.GetCapabilitiesRequest in project arctic-sea by 52North.
the class SimpleBinding method checkServiceOperatorKeyTypes.
protected void checkServiceOperatorKeyTypes(OwsServiceRequest request) throws OwsExceptionReport {
String service = request.getService();
String version = request.getVersion();
if (service == null || service.isEmpty()) {
throw new MissingServiceParameterException();
} else if (!getServiceOperatorRepository().isServiceSupported(service)) {
throw new InvalidServiceParameterException(service);
} else if (request instanceof GetCapabilitiesRequest) {
GetCapabilitiesRequest gcr = (GetCapabilitiesRequest) request;
if (gcr.isSetAcceptVersions() && !gcr.getAcceptVersions().stream().anyMatch(v -> isVersionSupported(service, v))) {
throw new InvalidAcceptVersionsParameterException(gcr.getAcceptVersions());
}
} else if (version == null || version.isEmpty()) {
throw new MissingVersionParameterException();
} else if (!isVersionSupported(service, version)) {
throw new VersionNotSupportedException();
}
}
use of org.n52.shetland.ogc.ows.service.GetCapabilitiesRequest 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.GetCapabilitiesRequest in project arctic-sea by 52North.
the class GetCapabilitiesRequestDecoder method decodeRequest.
@Override
protected GetCapabilitiesRequest decodeRequest(JsonNode node) {
GetCapabilitiesRequest req = new GetCapabilitiesRequest(SosConstants.SOS);
req.setAcceptFormats(parseStringOrStringList(node.path(JSONConstants.ACCEPT_FORMATS)));
req.setAcceptVersions(parseStringOrStringList(node.path(JSONConstants.ACCEPT_VERSIONS)));
req.setSections(parseStringOrStringList(node.path(JSONConstants.SECTIONS)));
req.setUpdateSequence(node.path(JSONConstants.UPDATE_SEQUENCE).textValue());
return req;
}
use of org.n52.shetland.ogc.ows.service.GetCapabilitiesRequest in project arctic-sea by 52North.
the class SosDecoderv20 method parseGetCapabilities.
/**
* parses the XmlBean representing the getCapabilities request and creates a
* SosGetCapabilities request
*
* @param getCapsDoc
* XmlBean created from the incoming request stream
* @return Returns SosGetCapabilitiesRequest representing the request
*
* @throws DecodingException
* * If parsing the XmlBean failed
*/
private OwsServiceRequest parseGetCapabilities(final GetCapabilitiesDocument getCapsDoc) throws DecodingException {
final GetCapabilitiesType getCapsType = getCapsDoc.getGetCapabilities2();
final GetCapabilitiesRequest request = new GetCapabilitiesRequest(getCapsType.getService());
if (getCapsType.getAcceptFormats() != null && getCapsType.getAcceptFormats().sizeOfOutputFormatArray() != 0) {
request.setAcceptFormats(Arrays.asList(getCapsType.getAcceptFormats().getOutputFormatArray()));
}
if (getCapsType.getAcceptVersions() != null && getCapsType.getAcceptVersions().sizeOfVersionArray() != 0) {
request.setAcceptVersions(Arrays.asList(getCapsType.getAcceptVersions().getVersionArray()));
}
if (getCapsType.getSections() != null && getCapsType.getSections().getSectionArray().length != 0) {
request.setSections(Arrays.asList(getCapsType.getSections().getSectionArray()));
}
if (getCapsType.getExtensionArray() != null && getCapsType.getExtensionArray().length > 0) {
request.setExtensions(parseExtensibleRequestExtension(getCapsType.getExtensionArray()));
}
return request;
}
Aggregations