On Mon, Sep 12, 2011 at 12:03 AM, Alessandro Ferrucci
<[email protected]> wrote:
> Hey Andrea,
>
> I finally am getting around to plugging in your aggregate datastore into
> geoserver. I added the jar to geoserver and it's getting recognized in the
> new datastores screen. When I click on aggregate datastore it comes up with
> the required configuration parameters. I have a few questions about these.
> So I looked at the AggregateDataStore factory for these parameters and how
> the test classes use them.
>
> for the name I just put in 'aggregate' .
>
> The repository needs to be an implementation of Repository, I'm assuming if
> I'm going to be running this inside of Geoserver I need to configure the
> org.geoserver.catalog.CatalogRepository
Ah, I did not remember you needed to use the store in GeoServer. I am working
on a set of patches to make the store configurable in GeoServer, including
providing the repository and getting a custom configuration GUI to configure
the source stores and the like, but I'm still not done with it, hopefully I'll
be able to get back to them by the end of the week.
And yes, I'm working on trunk, new development never gets done on a
stable series,
it's done on trunk and back ported on stable when it's... well... stable :-p
I've attache the portion of GeoServer changes that makes it handle the
repository
as an automatic parameter
Cheers
Andrea
--
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf
-------------------------------------------------------
diff --git a/src/main/src/main/java/org/geoserver/catalog/CatalogRepository.java b/src/main/src/main/java/org/geoserver/catalog/CatalogRepository.java
index e2e0e72..5f6a0bc 100644
--- a/src/main/src/main/java/org/geoserver/catalog/CatalogRepository.java
+++ b/src/main/src/main/java/org/geoserver/catalog/CatalogRepository.java
@@ -5,6 +5,7 @@
package org.geoserver.catalog;
import java.io.IOException;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
@@ -23,7 +24,7 @@ import org.opengis.feature.type.Name;
* @author Christian Mueller
* @author Justin Deoliveira
*/
-public class CatalogRepository implements Repository {
+public class CatalogRepository implements Repository, Serializable {
/**
* logger
diff --git a/src/main/src/main/java/org/geoserver/catalog/ResourcePool.java b/src/main/src/main/java/org/geoserver/catalog/ResourcePool.java
index 6b552bd..08cd7ef 100644
--- a/src/main/src/main/java/org/geoserver/catalog/ResourcePool.java
+++ b/src/main/src/main/java/org/geoserver/catalog/ResourcePool.java
@@ -58,6 +58,7 @@ import org.geotools.data.DataStore;
import org.geotools.data.DataUtilities;
import org.geotools.data.FeatureSource;
import org.geotools.data.DataAccessFactory.Param;
+import org.geotools.data.Repository;
import org.geotools.data.ows.Layer;
import org.geotools.data.ows.WMSCapabilities;
import org.geotools.data.simple.SimpleFeatureSource;
@@ -145,9 +146,11 @@ public class ResourcePool {
HashMap<StyleInfo,Style> styleCache;
List<Listener> listeners;
ThreadPoolExecutor coverageExecutor;
+ CatalogRepository repository;
public ResourcePool(Catalog catalog) {
this.catalog = catalog;
+ this.repository = new CatalogRepository(catalog);
crsCache = new HashMap<String, CoordinateReferenceSystem>();
dataStoreCache = new DataStoreCache();
featureTypeCache = new FeatureTypeCache(FEATURETYPE_CACHE_SIZE_DEFAULT);
@@ -301,29 +304,28 @@ public class ResourcePool {
// TODO: find a better way to do this
connectionParameters = DataStoreUtils.getParams(connectionParameters,null);
+ // obtain the factory
+ DataAccessFactory factory = null;
+ try {
+ factory = getDataStoreFactory(info);
+ } catch(IOException e) {
+ throw new IOException("Failed to find the datastore factory for " + info.getName()
+ + ", did you forget to install the store extension jar?");
+ }
+ Param[] params = factory.getParametersInfo();
+
//ensure that the namespace parameter is set for the datastore
if (!connectionParameters.containsKey( "namespace")) {
- //obtain the factory
- DataAccessFactory factory = null;
- try {
- factory = getDataStoreFactory(info);
- }
- catch(Exception e ) {
- //ignore, it will fail later
- }
-
//if we grabbed the factory, check that the factory actually supports
// a namespace parameter, if we could not get the factory, assume that
// it does
boolean supportsNamespace = true;
- if ( factory != null ) {
- supportsNamespace = false;
- Param[] params = factory.getParametersInfo();
- for ( Param p : params ) {
- if ( "namespace".equalsIgnoreCase( p.key ) ) {
- supportsNamespace = true;
- break;
- }
+ supportsNamespace = false;
+
+ for ( Param p : params ) {
+ if ( "namespace".equalsIgnoreCase( p.key ) ) {
+ supportsNamespace = true;
+ break;
}
}
@@ -339,6 +341,14 @@ public class ResourcePool {
}
}
+ // see if the store has a repository param, if so, pass the one wrapping
+ // the store
+ for ( Param p : params ) {
+ if(Repository.class.equals(p.getType())) {
+ connectionParameters.put(p.getName(), repository);
+ }
+ }
+
dataStore = DataStoreUtils.getDataAccess(connectionParameters);
if (dataStore == null) {
/*
diff --git a/src/web/core/src/main/java/org/geoserver/web/data/store/DefaultDataStoreEditPanel.java b/src/web/core/src/main/java/org/geoserver/web/data/store/DefaultDataStoreEditPanel.java
index e2cd0ed..c8e4fe0 100644
--- a/src/web/core/src/main/java/org/geoserver/web/data/store/DefaultDataStoreEditPanel.java
+++ b/src/web/core/src/main/java/org/geoserver/web/data/store/DefaultDataStoreEditPanel.java
@@ -36,6 +36,7 @@ import org.geoserver.web.data.store.panel.TextParamPanel;
import org.geoserver.web.util.MapModel;
import org.geoserver.web.wicket.FileExistsValidator;
import org.geotools.data.DataAccessFactory;
+import org.geotools.data.Repository;
import org.geotools.data.DataAccessFactory.Param;
/**
@@ -96,11 +97,13 @@ public class DefaultDataStoreEditPanel extends StoreEditPanel {
final Param[] dsParams = dsFactory.getParametersInfo();
for (Param p : dsParams) {
ParamInfo paramInfo = new ParamInfo(p);
- paramsMetadata.put(p.key, paramInfo);
-
- if (isNew) {
- // set default value
- applyParamDefault(paramInfo, info);
+ // hide the repository params, the resource pool will inject it transparently
+ if(!Repository.class.equals(paramInfo.getBinding())) {
+ paramsMetadata.put(p.key, paramInfo);
+ if (isNew) {
+ // set default value
+ applyParamDefault(paramInfo, info);
+ }
}
}
}
@@ -188,7 +191,7 @@ public class DefaultDataStoreEditPanel extends StoreEditPanel {
// AA: better not mess with files, the converters turn data dir relative to
// absolute and bye bye data dir portability
if (binding != null && !String.class.equals(binding) && !File.class.equals(binding)
- && !URL.class.equals(binding)) {
+ && !URL.class.equals(binding) && !binding.isArray()) {
tp.getFormComponent().setType(binding);
}
parameterPanel = tp;
diff --git a/src/web/core/src/main/java/org/geoserver/web/data/store/ParamInfo.java b/src/web/core/src/main/java/org/geoserver/web/data/store/ParamInfo.java
index e3045e5..898e425 100644
--- a/src/web/core/src/main/java/org/geoserver/web/data/store/ParamInfo.java
+++ b/src/web/core/src/main/java/org/geoserver/web/data/store/ParamInfo.java
@@ -10,6 +10,7 @@ package org.geoserver.web.data.store;
import java.io.Serializable;
import org.geotools.data.DataAccessFactory.Param;
+import org.geotools.data.Repository;
/**
* A serializable view of a {@link Param}
@@ -39,6 +40,9 @@ public class ParamInfo implements Serializable {
if (Serializable.class.isAssignableFrom(param.type)) {
this.binding = param.type;
this.value = (Serializable) param.sample;
+ } else if (Repository.class.equals(param.type)) {
+ this.binding = param.type;
+ this.value = null;
} else {
// handle the parameter as a string and let the DataStoreFactory
// convert it to the appropriate type
diff --git a/src/web/core/src/main/java/org/geoserver/web/data/store/StoreEditPanel.java b/src/web/core/src/main/java/org/geoserver/web/data/store/StoreEditPanel.java
index 4e7844b..925ec90 100644
--- a/src/web/core/src/main/java/org/geoserver/web/data/store/StoreEditPanel.java
+++ b/src/web/core/src/main/java/org/geoserver/web/data/store/StoreEditPanel.java
@@ -7,8 +7,6 @@ package org.geoserver.web.data.store;
import java.io.IOException;
import java.io.Serializable;
import java.net.URL;
-import java.util.LinkedHashMap;
-import java.util.Map;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.Panel;
@@ -18,6 +16,7 @@ import org.geoserver.catalog.StoreInfo;
import org.geoserver.web.GeoServerApplication;
import org.geotools.data.DataAccessFactory;
import org.geotools.data.DataAccessFactory.Param;
+import org.geotools.data.Repository;
/**
* Base class for panels containing the form edit components for {@link StoreInfo} objects
------------------------------------------------------------------------------
Doing More with Less: The Next Generation Virtual Desktop
What are the key obstacles that have prevented many mid-market businesses
from deploying virtual desktops? How do next-generation virtual desktops
provide companies an easier-to-deploy, easier-to-manage and more affordable
virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel