Skip to content

Commit

Permalink
Merge pull request deegree#1597 from gritGmbH/enhancement/optimize-wm…
Browse files Browse the repository at this point in the history
…s-controller-spi

Optimize deegree SPI and its documentation
  • Loading branch information
copierrj authored Nov 30, 2023
2 parents 739c7db + 8dc973a commit 5315152
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.TreeMap;
import java.util.UUID;

import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.servlet.ServletException;
Expand All @@ -85,7 +85,6 @@
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.dom.DOMSource;

import org.apache.axiom.attachments.ByteArrayDataSource;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.soap.SOAP11Version;
Expand All @@ -98,7 +97,6 @@
import org.deegree.commons.tom.ReferenceResolvingException;
import org.deegree.commons.tom.ows.Version;
import org.deegree.commons.utils.CollectionUtils;
import org.deegree.commons.utils.Pair;
import org.deegree.commons.utils.kvp.InvalidParameterValueException;
import org.deegree.commons.xml.CommonNamespaces;
import org.deegree.commons.xml.NamespaceBindings;
Expand Down Expand Up @@ -159,7 +157,9 @@
import org.deegree.services.wms.MapService;
import org.deegree.services.wms.controller.capabilities.serialize.CapabilitiesManager;
import org.deegree.services.wms.controller.exceptions.ExceptionsManager;
import org.deegree.services.wms.controller.plugins.DefaultGetFeatureInfoProvider;
import org.deegree.services.wms.controller.plugins.DefaultOutputFormatProvider;
import org.deegree.services.wms.controller.plugins.GetFeatureInfoProvider;
import org.deegree.services.wms.controller.plugins.OutputFormatProvider;
import org.deegree.services.wms.utils.GetMapLimitChecker;
import org.deegree.services.wms.utils.SupportedEncodingsParser;
Expand Down Expand Up @@ -206,6 +206,8 @@ public class WMSController extends AbstractOWS {

private OutputFormatProvider ouputFormatProvider;

private GetFeatureInfoProvider getFeatureInfoProvider;

private OWSMetadataProvider metadataProvider;

private DeegreeWMS conf;
Expand All @@ -223,7 +225,12 @@ public WMSController(ResourceMetadata<OWS> metadata, Workspace workspace, Deegre
capabilitiesManager = new CapabilitiesManager(isAddCapabilitiesDefaultFormatsEnabled(jaxbConfig));
featureInfoManager = new FeatureInfoManager(isAddFeatureInfoDefaultFormatsEnabled(jaxbConfig));
exceptionsManager = new ExceptionsManager(isAddExceptionsDefaultFormatsEnabled(jaxbConfig), this);
ouputFormatProvider = new DefaultOutputFormatProvider();
ouputFormatProvider = ServiceLoader.load(OutputFormatProvider.class) //
.findFirst() //
.orElseGet(DefaultOutputFormatProvider::new);
getFeatureInfoProvider = ServiceLoader.load(GetFeatureInfoProvider.class) //
.findFirst() //
.orElseGet(DefaultGetFeatureInfoProvider::new);
initOfferedVersions(jaxbConfig.getSupportedVersions());
}

Expand Down Expand Up @@ -925,10 +932,8 @@ private void doGetFeatureInfo(Map<String, String> map, final HttpResponseBuffer

String format = fi.getInfoFormat();
LinkedList<String> headers = new LinkedList<String>();
Pair<FeatureCollection, LinkedList<String>> pair = new Pair<>(service.getFeatures(fi, headers), headers);

FeatureCollection col = pair.first;
addHeaders(response, pair.second);
FeatureCollection col = getFeatureInfoProvider.query(this, service, fi, queryLayers, headers);
addHeaders(response, headers);
format = format == null ? "application/vnd.ogc.gml" : format;
response.setContentType(format);
response.setCharacterEncoding("UTF-8");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*----------------------------------------------------------------------------
This file is part of deegree, http://deegree.org/
Copyright (C) 2023 by:
- Department of Geography, University of Bonn -
and
- grit graphische Informationstechnik Beratungsgesellschaft mbH -
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact information:
grit graphische Informationstechnik Beratungsgesellschaft mbH
Landwehrstr. 143, 59368 Werne
Germany
https://www.grit.de/
Department of Geography, University of Bonn
Prof. Dr. Klaus Greve
Postfach 1147, 53001 Bonn
Germany
http://www.geographie.uni-bonn.de/deegree/
e-mail: [email protected]
----------------------------------------------------------------------------*/
package org.deegree.services.wms.controller.plugins;

import java.io.IOException;
import java.util.List;
import org.deegree.commons.ows.exception.OWSException;
import org.deegree.feature.FeatureCollection;
import org.deegree.protocol.wms.ops.GetFeatureInfo;
import org.deegree.services.wms.MapService;
import org.deegree.services.wms.controller.WMSController;

public class DefaultGetFeatureInfoProvider implements GetFeatureInfoProvider {

@Override
public FeatureCollection query(WMSController wmsController, MapService service, GetFeatureInfo fi,
List<String> queryLayers, List<String> headers) throws OWSException, IOException {
return service.getFeatures(fi, headers);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*----------------------------------------------------------------------------
This file is part of deegree, http://deegree.org/
Copyright (C) 2023 by:
- Department of Geography, University of Bonn -
and
- grit graphische Informationstechnik Beratungsgesellschaft mbH -
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact information:
grit graphische Informationstechnik Beratungsgesellschaft mbH
Landwehrstr. 143, 59368 Werne
Germany
https://www.grit.de/
Department of Geography, University of Bonn
Prof. Dr. Klaus Greve
Postfach 1147, 53001 Bonn
Germany
http://www.geographie.uni-bonn.de/deegree/
e-mail: [email protected]
----------------------------------------------------------------------------*/
package org.deegree.services.wms.controller.plugins;

import java.io.IOException;
import java.util.List;
import org.deegree.commons.ows.exception.OWSException;
import org.deegree.feature.FeatureCollection;
import org.deegree.protocol.wms.ops.GetFeatureInfo;
import org.deegree.services.wms.MapService;
import org.deegree.services.wms.controller.WMSController;

public interface GetFeatureInfoProvider {

/**
* @param wmsController Controller handling the request
* @param service MapService providing the data
* @param fi Info request
* @param queryLayers Original layer in map request
* @param headers may not be null. Extra HTTP headers will be added, as required by
* the WMS spec.
* @return a FeatureCollection from the requested service
*/
FeatureCollection query(WMSController wmsController, MapService service, GetFeatureInfo fi,
List<String> queryLayers, List<String> headers) throws OWSException, IOException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This must be provided by the extension module that provides the non-default implementation
Original file line number Diff line number Diff line change
@@ -1 +1 @@
org.deegree.services.wms.controller.plugins.DefaultOutputFormatProvider
# This must be provided by the extension module that provides the non-default implementation
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,37 @@ f

|deegree.config.apikey.warn-when-disabled |java.lang.Boolean |true |Log warning if security on REST api is disabled by specifying `*` in _config.apikey_.

|===

=== Interception points

deegree offers developers the ability to extend or change deegree with custom modules.
This chapter is only intended as an entry point to make it easier to reach these Java service provider interfaces.

[width="100%",cols="40%,40%,10%",options="header",]
|===
|Service provider interface |Examplary implementation |Cardinality

|org.deegree.sqldialect.SQLDialectProvider |org.deegree.sqldialect.postgis.PostGISDialectProvider |0..*

|org.deegree.style.styling.mark.WellKnownNameLoader |org.deegree.style.styling.wkn.ShapeLoader |0..*

|org.deegree.filter.function.FunctionProvider |org.deegree.filter.function.other.Lower |1..*

|org.deegree.sqldialect.filter.function.SQLFunctionProvider |org.deegree.sqldialect.filter.function.SQLLower |1..*

|org.deegree.filter.expression.custom.CustomExpression |org.deegree.filter.expression.custom.se.Substring |1..*

|org.deegree.services.controller.exception.serializer.SerializerProvider | |0..*

|org.deegree.services.csw.getrecordbyid.GetRecordByIdHandler |org.deegree.services.csw.getrecordbyid.DefaultGetRecordByIdHandler |0..1

|org.deegree.tools.featurestoresql.loader.FeatureStreamFactory | |0..*

|org.deegree.coverage.raster.data.container.MemoryRasterDataContainer |org.deegree.coverage.raster.data.container.MemoryRasterDataContainer |1..*

|org.deegree.services.wms.controller.plugins.OutputFormatProvider |org.deegree.services.wms.controller.plugins.DefaultOutputFormatProvider |0..1

|org.deegree.services.wms.controller.plugins.GetFeatureInfoProvider |org.deegree.services.wms.controller.plugins.DefaultGetFeatureInfoProvider |0..1

|===

0 comments on commit 5315152

Please sign in to comment.