Search in sources :

Example 1 with GetCapabilitiesRequest

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));
    }
}
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)

Example 2 with GetCapabilitiesRequest

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();
    }
}
Also used : GetCapabilitiesRequest(org.n52.shetland.ogc.ows.service.GetCapabilitiesRequest) InvalidServiceParameterException(org.n52.iceland.exception.ows.concrete.InvalidServiceParameterException) MissingVersionParameterException(org.n52.shetland.ogc.ows.exception.MissingVersionParameterException) InvalidAcceptVersionsParameterException(org.n52.iceland.exception.ows.concrete.InvalidAcceptVersionsParameterException) VersionNotSupportedException(org.n52.iceland.exception.ows.concrete.VersionNotSupportedException) MissingServiceParameterException(org.n52.shetland.ogc.ows.exception.MissingServiceParameterException)

Example 3 with GetCapabilitiesRequest

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;
}
Also used : GetCapabilitiesResponse(org.n52.shetland.ogc.ows.service.GetCapabilitiesResponse)

Example 4 with GetCapabilitiesRequest

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;
}
Also used : GetCapabilitiesRequest(org.n52.shetland.ogc.ows.service.GetCapabilitiesRequest)

Example 5 with GetCapabilitiesRequest

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;
}
Also used : GetCapabilitiesRequest(org.n52.shetland.ogc.ows.service.GetCapabilitiesRequest) GetCapabilitiesType(net.opengis.sos.x20.GetCapabilitiesType)

Aggregations

GetCapabilitiesRequest (org.n52.shetland.ogc.ows.service.GetCapabilitiesRequest)6 InvalidServiceParameterException (org.n52.iceland.exception.ows.concrete.InvalidServiceParameterException)2 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 Objects (java.util.Objects)1 GetCapabilities (net.opengis.sos.x10.GetCapabilitiesDocument.GetCapabilities)1 GetCapabilitiesType (net.opengis.sos.x20.GetCapabilitiesType)1 Test (org.junit.Test)1 InvalidAcceptVersionsParameterException (org.n52.iceland.exception.ows.concrete.InvalidAcceptVersionsParameterException)1 InvalidServiceOrVersionException (org.n52.iceland.exception.ows.concrete.InvalidServiceOrVersionException)1 VersionNotSupportedException (org.n52.iceland.exception.ows.concrete.VersionNotSupportedException)1 StatisticsServiceEventHandler (org.n52.iceland.statistics.api.interfaces.StatisticsServiceEventHandler)1 DefaultServiceEventHandler (org.n52.iceland.statistics.impl.handlers.DefaultServiceEventHandler)1 CapabilitiesSection (org.n52.shetland.ogc.ows.OWSConstants.CapabilitiesSection)1 OwsCapabilities (org.n52.shetland.ogc.ows.OwsCapabilities)1 OwsCapabilitiesExtension (org.n52.shetland.ogc.ows.OwsCapabilitiesExtension)1 OwsOperationsMetadata (org.n52.shetland.ogc.ows.OwsOperationsMetadata)1 OwsServiceIdentification (org.n52.shetland.ogc.ows.OwsServiceIdentification)1 OwsServiceProvider (org.n52.shetland.ogc.ows.OwsServiceProvider)1 MissingServiceParameterException (org.n52.shetland.ogc.ows.exception.MissingServiceParameterException)1