[Geoserver-users] Unable to use BaseMapGroup with namespaced layers

Hi all,

I’m having multiple users in the database with the same tables. To differentiate the layers I use the namespaces.

So user1 has layer user1:LAYERNAME

Now I want to create a BaseMapGroup so I created

user1:LAYERNAME,user2:LAYERNAME,user3:LAYERNAME

style1,style2,style3

Etc…

But I’m getting the error:

Java.util.NoSuchElementExeception: Could not locate FeatureTypeConfig ‘LAYERNAME’

At org.vfny.geoserver.global.Data.getFeatureTypeInfo(Data.java:1903)

At org.geoserver.wms.kvp.GetMapKvpRequestReader.findFeatureLayer(GetMapKvpRequestReader.java:1142)

It seems that the namespace is stripped off somewhere between the config of the basemapgroup and the actual request

Can somenone please explain where I need to look to find the bug (if it is one ;-))

Thanks in advance

Kris Geusebroek

Consultant



cid:image001.jpg@anonymised.com



Email: kgeusebroek@anonymised.com



Tel: +31 (0)35 538 1921



Fax: +31 (0)35 538 1922



Mobile: +31 (0)6 30 697 223



http://www.xebia.com







Utrechtseweg 49



1213 TL Hilversum



The Netherlands

Xebia Blog ! http://blog.xebia.com/

Xebia Podcast! http://podcast.xebia.com/

Kris Geusebroek ha scritto:

Hi all,

I’m having multiple users in the database with the same tables. To differentiate the layers I use the namespaces.

So user1 has layer user1:LAYERNAME

Now I want to create a BaseMapGroup so I created

<BaseMapGroup baseMapTitle=”allUsers:LAYERNAME”>

  <baseMapLayers>user1:LAYERNAME,user2:LAYERNAME,user3:LAYERNAME</baseMapLayers>

  <baseMapStyles>style1,style2,style3</baseMapStyeles>

Etc..

But I’m getting the error:

Java.util.NoSuchElementExeception: Could not locate FeatureTypeConfig ‘LAYERNAME’

                At org.vfny.geoserver.global.Data.getFeatureTypeInfo(Data.java:1903)

                At org.geoserver.wms.kvp.GetMapKvpRequestReader.findFeatureLayer(GetMapKvpRequestReader.java:1142)

It seems that the namespace is stripped off somewhere between the config of the basemapgroup and the actual request

Can somenone please explain where I need to look to find the bug (if it is one ;-))

Hum, first, I would look into services.xml to make sure the namespace
has been preserved when the configuration is saved.
Second, use the stack trace you already have to locate which part of the
code does the feature type lookup.
Finally, open a bug report on jira.codehaus.org (provided there is not
one already) and attach a patch there :slight_smile:

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Hi Andrea,

Here's the patch
I'm not sure about the if statement (should be easier to determine if a
namespace is available) but it works

In wms/src/main/java/org/vfny/geoserver/global/WMS.java

The method getbaseMapLayers should be:

    public Map getBaseMapLayers() {
        HashMap baseLayers = new HashMap();
        for ( LayerGroupInfo map : gs.getCatalog().getLayerGroups() ) {
            StringBuffer layers = new StringBuffer();
            for ( LayerInfo l : map.getLayers() ) {
    // check if namespace is used in basemapgroup. If so use
it.
              if (l.getResource() != null &&
l.getResource().getNamespace() != null &&
l.getResource().getNamespace().getPrefix() != null) {
                layers.append( l.toString()).append( "," );
              }
              else {
                layers.append( l.getName() ).append( "," );
              }
            }
            layers.setLength( layers.length() - 1 );
            baseLayers.put( map.getName(), layers.toString() );
        }
        return baseLayers;
        //return baseMapLayers != null ? baseMapLayers :
Collections.EMPTY_MAP;
    }

Hope this can make it in the 1.7.3 release :wink:

Cheers Kris

-----Original Message-----
From: Andrea Aime [mailto:aaime@anonymised.com]
Sent: Monday, March 09, 2009 12:22 PM
To: Kris Geusebroek
Cc: geoserver-users@lists.sourceforge.net
Subject: Re: [Geoserver-users] Unable to use BaseMapGroup with
namespaced layers

Kris Geusebroek ha scritto:

Hi all,

I'm having multiple users in the database with the same tables. To
differentiate the layers I use the namespaces.

So user1 has layer user1:LAYERNAME

Now I want to create a BaseMapGroup so I created

<BaseMapGroup baseMapTitle="allUsers:LAYERNAME">

<baseMapLayers>user1:LAYERNAME,user2:LAYERNAME,user3:LAYERNAME</baseMapL
ayers>

  <baseMapStyles>style1,style2,style3</baseMapStyeles>

Etc..

But I'm getting the error:

Java.util.NoSuchElementExeception: Could not locate FeatureTypeConfig
'LAYERNAME'

                At
org.vfny.geoserver.global.Data.getFeatureTypeInfo(Data.java:1903)

                At

org.geoserver.wms.kvp.GetMapKvpRequestReader.findFeatureLayer(GetMapKvpR
equestReader.java:1142)

It seems that the namespace is stripped off somewhere between the

config

of the basemapgroup and the actual request

Can somenone please explain where I need to look to find the bug (if

it

is one ;-))

Hum, first, I would look into services.xml to make sure the namespace
has been preserved when the configuration is saved.
Second, use the stack trace you already have to locate which part of the
code does the feature type lookup.
Finally, open a bug report on jira.codehaus.org (provided there is not
one already) and attach a patch there :slight_smile:

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Kris Geusebroek ha scritto:

Hi Andrea,

Here's the patch
I'm not sure about the if statement (should be easier to determine if a
namespace is available) but it works

In wms/src/main/java/org/vfny/geoserver/global/WMS.java

The method getbaseMapLayers should be:

    public Map getBaseMapLayers() {
        HashMap baseLayers = new HashMap();
        for ( LayerGroupInfo map : gs.getCatalog().getLayerGroups() ) {
            StringBuffer layers = new StringBuffer();
            for ( LayerInfo l : map.getLayers() ) {
    // check if namespace is used in basemapgroup. If so use
it.
              if (l.getResource() != null &&
l.getResource().getNamespace() != null &&
l.getResource().getNamespace().getPrefix() != null) {
                layers.append( l.toString()).append( "," );
              }
              else {
                layers.append( l.getName() ).append( "," );
              }
            }
            layers.setLength( layers.length() - 1 );
            baseLayers.put( map.getName(), layers.toString() );
        }
        return baseLayers;
        //return baseMapLayers != null ? baseMapLayers :
Collections.EMPTY_MAP;
    }

Thanks, I'll review and apply shortly

Hope this can make it in the 1.7.3 release :wink:

Nope, too late for that, sorry.
Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Andrea Aime ha scritto:

Kris Geusebroek ha scritto:

Hi Andrea,

Here's the patch
I'm not sure about the if statement (should be easier to determine if a
namespace is available) but it works

In wms/src/main/java/org/vfny/geoserver/global/WMS.java

The method getbaseMapLayers should be:

    public Map getBaseMapLayers() {
        HashMap baseLayers = new HashMap();
        for ( LayerGroupInfo map : gs.getCatalog().getLayerGroups() ) {
            StringBuffer layers = new StringBuffer();
            for ( LayerInfo l : map.getLayers() ) {
    // check if namespace is used in basemapgroup. If so use
it.
              if (l.getResource() != null &&
l.getResource().getNamespace() != null &&
l.getResource().getNamespace().getPrefix() != null) {
                layers.append( l.toString()).append( "," );
              }
              else {
                layers.append( l.getName() ).append( "," );
              }
            }
            layers.setLength( layers.length() - 1 );
            baseLayers.put( map.getName(), layers.toString() );
        }
        return baseLayers;
        //return baseMapLayers != null ? baseMapLayers :
Collections.EMPTY_MAP;
    }

Thanks, I'll review and apply shortly

Hum, ok, I'm looking at the code on 1.7.x and I'm a bit confused.
The current code on 1.7.x uses:

for ( LayerInfo l : map.getLayers() ) {
                 layers.append( l.getResource().getPrefixedName() ).append( "," );
}

This should always generate a fully qualified name, no matter what,
in the form "nsprefix:layerName".
As far as I know a ResourceInfo should always be attached to
a namespace, so the case l.getResource().getNamespace() should
never happen, either.

Looking into svn blame I see that line was changed one month ago by Arne, before it looked like:
layers.append( l.getName() ).append( "," );

May it be that you've been patching an older version?
Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Hi Andrea,

In fact i was, i'm currently using geoserver 1.7.2 and found the bug
there.
Also did the patch there and just found out (like you) the it's already
fixed in the 1.7.3 release.

So great work!

Thanks

Kris

-----Original Message-----
From: Andrea Aime [mailto:aaime@anonymised.com]
Sent: Tuesday, March 10, 2009 10:47 AM
To: Kris Geusebroek
Cc: geoserver-users@lists.sourceforge.net
Subject: Re: [Geoserver-users] Unable to use BaseMapGroup with
namespaced layers

Andrea Aime ha scritto:

Kris Geusebroek ha scritto:

Hi Andrea,

Here's the patch
I'm not sure about the if statement (should be easier to determine if

a

namespace is available) but it works

In wms/src/main/java/org/vfny/geoserver/global/WMS.java

The method getbaseMapLayers should be:

    public Map getBaseMapLayers() {
        HashMap baseLayers = new HashMap();
        for ( LayerGroupInfo map : gs.getCatalog().getLayerGroups() )

{

            StringBuffer layers = new StringBuffer();
            for ( LayerInfo l : map.getLayers() ) {
    // check if namespace is used in basemapgroup. If so use
it.
              if (l.getResource() != null &&
l.getResource().getNamespace() != null &&
l.getResource().getNamespace().getPrefix() != null) {
                layers.append( l.toString()).append( "," );
              }
              else {
                layers.append( l.getName() ).append( "," );
              }
            }
            layers.setLength( layers.length() - 1 );
            baseLayers.put( map.getName(), layers.toString() );
        }
        return baseLayers;
        //return baseMapLayers != null ? baseMapLayers :
Collections.EMPTY_MAP;
    }

Thanks, I'll review and apply shortly

Hum, ok, I'm looking at the code on 1.7.x and I'm a bit confused.
The current code on 1.7.x uses:

for ( LayerInfo l : map.getLayers() ) {
                 layers.append( l.getResource().getPrefixedName()
).append( "," );
}

This should always generate a fully qualified name, no matter what,
in the form "nsprefix:layerName".
As far as I know a ResourceInfo should always be attached to
a namespace, so the case l.getResource().getNamespace() should
never happen, either.

Looking into svn blame I see that line was changed one month ago by
Arne, before it looked like:
layers.append( l.getName() ).append( "," );

May it be that you've been patching an older version?
Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.