Search in sources :

Example 1 with InvalidServiceOrVersionException

use of org.n52.iceland.exception.ows.concrete.InvalidServiceOrVersionException 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));
    }
}
Also used : GetCapabilitiesRequest(org.n52.shetland.ogc.ows.service.GetCapabilitiesRequest) InvalidServiceParameterException(org.n52.iceland.exception.ows.concrete.InvalidServiceParameterException) OwsServiceKey(org.n52.shetland.ogc.ows.service.OwsServiceKey) Objects(java.util.Objects) InvalidServiceOrVersionException(org.n52.iceland.exception.ows.concrete.InvalidServiceOrVersionException)

Aggregations

Objects (java.util.Objects)1 InvalidServiceOrVersionException (org.n52.iceland.exception.ows.concrete.InvalidServiceOrVersionException)1 InvalidServiceParameterException (org.n52.iceland.exception.ows.concrete.InvalidServiceParameterException)1 GetCapabilitiesRequest (org.n52.shetland.ogc.ows.service.GetCapabilitiesRequest)1 OwsServiceKey (org.n52.shetland.ogc.ows.service.OwsServiceKey)1