Skip to content

Commit

Permalink
[GEOS-8222] Cascading WMTS: fixes and improvements as per code review
Browse files Browse the repository at this point in the history
  • Loading branch information
etj committed Aug 18, 2017
1 parent 0cb23ed commit 8520a97
Show file tree
Hide file tree
Showing 38 changed files with 15,837 additions and 274 deletions.
12 changes: 1 addition & 11 deletions src/community/pom.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
<descriptor>release/ext-ows-simulate.xml</descriptor> <descriptor>release/ext-ows-simulate.xml</descriptor>
<descriptor>release/ext-jdbc-metrics.xml</descriptor> <descriptor>release/ext-jdbc-metrics.xml</descriptor>
<descriptor>release/ext-opensearch-eo.xml</descriptor> <descriptor>release/ext-opensearch-eo.xml</descriptor>
<descriptor>release/ext-wmts.xml</descriptor>
</descriptors> </descriptors>
</configuration> </configuration>
</plugin> </plugin>
Expand Down Expand Up @@ -532,14 +531,5 @@
<module>jdbc-metrics</module> <module>jdbc-metrics</module>
</modules> </modules>
</profile> </profile>
<profile> </profiles>
<id>wmts</id>
<modules>
<module>gs-wmts</module>
</modules>

</profile>
</profiles>


</project> </project>
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ public interface CatalogVisitor {
* Visits a WMS data store. * Visits a WMS data store.
*/ */
void visit( WMSStoreInfo wmsStore ); void visit( WMSStoreInfo wmsStore );

/** /**
* Visits a WMTS data store. * Visits a WMTS data store.
*/ */
void visit( WMTSStoreInfo wmsStore ); default void visit( WMTSStoreInfo store ) {}


/** /**
* Visits a feature type. * Visits a feature type.
Expand Down Expand Up @@ -81,7 +82,7 @@ public interface CatalogVisitor {
void visit(WMSLayerInfo wmsLayer); void visit(WMSLayerInfo wmsLayer);


/** /**
* @param wmtsLayerInfoImpl * Visits a WMTS layer resource
*/ */
void visit(WMTSLayerInfo wmtsLayerInfo); default void visit(WMTSLayerInfo layer) {}
} }
82 changes: 82 additions & 0 deletions src/main/src/main/java/org/geoserver/catalog/HTTPStoreInfo.java
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,82 @@
/* (c) 2017 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
package org.geoserver.catalog;

/**
* A store backed by a remote HTTP service.
*
* Most of these methods have been refactored from WMSStoreInfo, now a sub-interface.
*
* @author Andrea Aime - OpenGeo
* @author Emanuele Tajariol (etj at geo-solutions dot it)
*/
public interface HTTPStoreInfo extends StoreInfo {

/**
* The entrypoint URL, usually a getCapabilities
*/
String getCapabilitiesURL();

/**
* Sets entrypoint / getCapabilities url.
*
* @uml.property name="url"
*/
void setCapabilitiesURL(String url);

String getUsername();

void setUsername(String user);

String getPassword();

void setPassword(String password);

/**
* @return Upper limit on the number of http connections the store should hold in the pool if
* {@link #isUseConnectionPooling()} is {@code true}.
*/
int getMaxConnections();

void setMaxConnections(int maxConcurrentConnections);

/**
* @return number of seconds to wait on read before time out, defaults to 60
*/
int getReadTimeout();

/**
* @param timeoutSeconds
* seconds to wait before timing out a read request
*/
void setReadTimeout(int timeoutSeconds);

/**
* @return seconds to wait for connect requests before timing out, defaults to 30
*/
int getConnectTimeout();

/**
* @param seconds
* to wait for connect requests before timing out
*/
void setConnectTimeout(int timeoutSeconds);

/**
* @return {@code true} (default) if the store shall use an http connection managed that pools
* connections, {@code false} otherwise.
* @see #getMaxConnections()
*/
public boolean isUseConnectionPooling();

/**
* @param useHttpConnectionPooling
* {@code true} if the store shall use an http connection managed that pools
* connections, {@code false} otherwise.
* @see #setMaxConnections(int)
*/
public void setUseConnectionPooling(boolean useHttpConnectionPooling);

}
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1785,9 +1785,10 @@ public WebMapTileServer getWebMapTileServer(WMTSStoreInfo info) throws IOExcepti
synchronized (wmtsCache) { synchronized (wmtsCache) {
wmts = (WebMapTileServer) wmtsCache.get(id); wmts = (WebMapTileServer) wmtsCache.get(id);
if (wmts == null) { if (wmts == null) {
HTTPClient client = getHTTPClient(expandedStore);
String capabilitiesURL = expandedStore.getCapabilitiesURL(); String capabilitiesURL = expandedStore.getCapabilitiesURL();
URL serverURL = new URL(capabilitiesURL); URL serverURL = new URL(capabilitiesURL);
wmts = new WebMapTileServer(serverURL); wmts = new WebMapTileServer(serverURL, client, null);


if(StringUtils.isNotEmpty(info.getHeaderName()) && StringUtils.isNotEmpty(info.getHeaderValue())) { if(StringUtils.isNotEmpty(info.getHeaderName()) && StringUtils.isNotEmpty(info.getHeaderValue())) {
wmts.getHeaders().put(info.getHeaderName(), info.getHeaderValue()); wmts.getHeaders().put(info.getHeaderName(), info.getHeaderValue());
Expand Down Expand Up @@ -1818,7 +1819,7 @@ public EntityResolver getEntityResolver() {
return entityResolver; return entityResolver;
} }


private HTTPClient getHTTPClient(WMSStoreInfo info) { private HTTPClient getHTTPClient(HTTPStoreInfo info) {
String capabilitiesURL = info.getCapabilitiesURL(); String capabilitiesURL = info.getCapabilitiesURL();


// check for mock bindings. Since we are going to run this code in production as well, // check for mock bindings. Since we are going to run this code in production as well,
Expand Down
67 changes: 1 addition & 66 deletions src/main/src/main/java/org/geoserver/catalog/WMSStoreInfo.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @author Andrea Aime - OpenGeo * @author Andrea Aime - OpenGeo
* *
*/ */
public interface WMSStoreInfo extends StoreInfo { public interface WMSStoreInfo extends HTTPStoreInfo {


/** /**
* Returns the underlying {@link WebMapServer} * Returns the underlying {@link WebMapServer}
Expand All @@ -34,70 +34,5 @@ public interface WMSStoreInfo extends StoreInfo {
* Any I/O problems. * Any I/O problems.
*/ */
WebMapServer getWebMapServer(ProgressListener listener) throws IOException; WebMapServer getWebMapServer(ProgressListener listener) throws IOException;

/**
* The capabilities url
*/
String getCapabilitiesURL();

/**
* Sets the web map server capabilities url.
*
* @uml.property name="url"
*/
void setCapabilitiesURL(String url);

String getUsername();

void setUsername(String user);

String getPassword();

void setPassword(String password);

/**
* @return Upper limit on the number of http connections the store should hold in the pool if
* {@link #isUseConnectionPooling()} is {@code true}.
*/
int getMaxConnections();

void setMaxConnections(int maxConcurrentConnections);

/**
* @return number of seconds to wait on read before time out, defaults to 60
*/
int getReadTimeout();

/**
* @param timeoutSeconds
* seconds to wait before timing out a read request
*/
void setReadTimeout(int timeoutSeconds);

/**
* @return seconds to wait for connect requests before timing out, defaults to 30
*/
int getConnectTimeout();

/**
* @param seconds
* to wait for connect requests before timing out
*/
void setConnectTimeout(int timeoutSeconds);

/**
* @return {@code true} (default) if the store shall use an http connection managed that pools
* connections, {@code false} otherwise.
* @see #getMaxConnections()
*/
public boolean isUseConnectionPooling();

/**
* @param useHttpConnectionPooling
* {@code true} if the store shall use an http connection managed that pools
* connections, {@code false} otherwise.
* @see #setMaxConnections(int)
*/
public void setUseConnectionPooling(boolean useHttpConnectionPooling);


} }
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,4 @@
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved /* (c) 2017 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root * This code is licensed under the GPL 2.0 license, available at the root
* application directory. * application directory.
*/ */
Expand Down
77 changes: 6 additions & 71 deletions src/main/src/main/java/org/geoserver/catalog/WMTSStoreInfo.java
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,4 @@
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved /* (c) 2017 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root * This code is licensed under the GPL 2.0 license, available at the root
* application directory. * application directory.
*/ */
Expand All @@ -11,15 +10,16 @@
import org.opengis.util.ProgressListener; import org.opengis.util.ProgressListener;


/** /**
* A store backed by a {@link WebMapServer}, allows for WMS cascading * A store backed by a {@link WebMapTileServer}, allows for WMTS cascading
* *
* @author Andrea Aime - OpenGeo * @author ian
* @author Emanuele Tajariol (etj at geo-solutions dot it)
* *
*/ */
public interface WMTSStoreInfo extends StoreInfo { public interface WMTSStoreInfo extends HTTPStoreInfo {


/** /**
* Returns the underlying {@link WebMapTileServer} * Returns the underlying {@link WebMapTileServer}.
* <p> * <p>
* This method does I/O and is potentially blocking. The <tt>listener</tt> may be used to report * This method does I/O and is potentially blocking. The <tt>listener</tt> may be used to report
* the progress of loading the datastore and also to report any errors or warnings that occur. * the progress of loading the datastore and also to report any errors or warnings that occur.
Expand All @@ -35,71 +35,6 @@ public interface WMTSStoreInfo extends StoreInfo {
*/ */
WebMapTileServer getWebMapTileServer(ProgressListener listener) throws IOException; WebMapTileServer getWebMapTileServer(ProgressListener listener) throws IOException;


/**
* The capabilities url
*/
String getCapabilitiesURL();

/**
* Sets the web map server capabilities url.
*
* @uml.property name="url"
*/
void setCapabilitiesURL(String url);

String getUsername();

void setUsername(String user);

String getPassword();

void setPassword(String password);

/**
* @return Upper limit on the number of http connections the store should hold in the pool if
* {@link #isUseConnectionPooling()} is {@code true}.
*/
int getMaxConnections();

void setMaxConnections(int maxConcurrentConnections);

/**
* @return number of seconds to wait on read before time out, defaults to 60
*/
int getReadTimeout();

/**
* @param timeoutSeconds
* seconds to wait before timing out a read request
*/
void setReadTimeout(int timeoutSeconds);

/**
* @return seconds to wait for connect requests before timing out, defaults to 30
*/
int getConnectTimeout();

/**
* @param seconds
* to wait for connect requests before timing out
*/
void setConnectTimeout(int timeoutSeconds);

/**
* @return {@code true} (default) if the store shall use an http connection managed that pools
* connections, {@code false} otherwise.
* @see #getMaxConnections()
*/
public boolean isUseConnectionPooling();

/**
* @param useHttpConnectionPooling
* {@code true} if the store shall use an http connection managed that pools
* connections, {@code false} otherwise.
* @see #setMaxConnections(int)
*/
public void setUseConnectionPooling(boolean useHttpConnectionPooling);

String getHeaderName(); String getHeaderName();
void setHeaderName(String headerName); void setHeaderName(String headerName);
String getHeaderValue(); String getHeaderValue();
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,4 @@
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved /* (c) 2017 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root * This code is licensed under the GPL 2.0 license, available at the root
* application directory. * application directory.
*/ */
Expand All @@ -9,7 +8,6 @@


import org.geoserver.catalog.Catalog; import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.CatalogVisitor; import org.geoserver.catalog.CatalogVisitor;
import org.geoserver.catalog.WMSStoreInfo;
import org.geoserver.catalog.WMTSLayerInfo; import org.geoserver.catalog.WMTSLayerInfo;
import org.geoserver.catalog.WMTSStoreInfo; import org.geoserver.catalog.WMTSStoreInfo;
import org.geotools.data.ows.Layer; import org.geotools.data.ows.Layer;
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,4 @@
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved /* (c) 2017 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root * This code is licensed under the GPL 2.0 license, available at the root
* application directory. * application directory.
*/ */
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ private void loadWmtsStore(StoreContents storeContents, CatalogImpl catalog,
return; return;
} }


// load wms layers // load wmts layers
LayerLoader<WMTSLayerInfo> coverageLoader = new LayerLoader<>(WMTSLayerInfo.class, xp, catalog); LayerLoader<WMTSLayerInfo> coverageLoader = new LayerLoader<>(WMTSLayerInfo.class, xp, catalog);
try(AsynchResourceIterator<LayerContents> it = new AsynchResourceIterator<>(storeResource.parent(), Resources.DirectoryFilter.INSTANCE, WMTS_LAYER_MAPPER)) { try(AsynchResourceIterator<LayerContents> it = new AsynchResourceIterator<>(storeResource.parent(), Resources.DirectoryFilter.INSTANCE, WMTS_LAYER_MAPPER)) {
while(it.hasNext()) { while(it.hasNext()) {
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ DataAccessLimits buildLimits(Class<? extends ResourceInfo> resourceClass, Filter
} else if (WMSLayerInfo.class.isAssignableFrom(resourceClass)) { } else if (WMSLayerInfo.class.isAssignableFrom(resourceClass)) {
return new WMSAccessLimits(mode, readFilter, null, true); return new WMSAccessLimits(mode, readFilter, null, true);
} else if (WMTSLayerInfo.class.isAssignableFrom(resourceClass)) { } else if (WMTSLayerInfo.class.isAssignableFrom(resourceClass)) {
return new WMTSAccessLimits(mode, readFilter, null, true); return new WMTSAccessLimits(mode, readFilter, null);
} else { } else {
LOGGER.log(Level.INFO, LOGGER.log(Level.INFO,
"Warning, adapting to generic access limits for unrecognized resource type " "Warning, adapting to generic access limits for unrecognized resource type "
Expand Down

0 comments on commit 8520a97

Please sign in to comment.