[Geoserver-devel] Allowing multiple workspaces to use the same name space URI

Hi,

The main use case for this is to allow the publishing of the same feature type in different virtual services, this is particularity important for complex features (app-schema). Sometimes we want to map the same feature type in a different way and publish it in different end points (virtual services). Because a feature type is associated with a specific name space and name spaces have a one to one relationship with workspaces, the only way to this right now is to use several GeoServer instances.

When dealing with simple features or complex features there is two different feature types concepts to take in account, one is the feature type know by GeoTools (FeatureType) and the other one is the feature type known by GeoServer (FeatureTypeInfo). The link between a GeoTools feature type and a GeoServer feature type is the name. The name is composed by a name space and the type name, for example “http://www.census.gov:tiger_roads”. This link needs to be used for example when encoding features in WFS.

In GeoServer, workspaces have a name and a name space. When a resource is created it inherits is workspace name space. For example, if we create a workspace named tiger with name space (URI) http://www.census.gov and create a vector layer named tiger_roads inside the tiger workspace, the layer feature type (FeatureTypeInfo) name will be “http://www.census.gov:tiger_roads”. The link needed between GeoTools and GeoServer feature types described above is the main reason for the one to one relationship limitation between workspaces and name spaces, for WFS there is no workspaces only name spaces.

Did I understood this relationships correctly so far ?

More in detail, when creating an workspace in GeoServer two objects are actually created: the WorkspaceInfo and a NameSpaceInfo. The first object contains basically the workspace name and the second object contains the workspace name (prefix) and the workspace name space (URI).

At the lowest level in GeoServer resources are searched by the NameSpaceInfo ID and the resource name. The catalog API give us three ways to lookup for resources by their name:

  1. getResourceByName(String ns, String name, Class clazz);
  2. getResourceByName(NamespaceInfo ns, String name, Class clazz);
  3. getResourceByName(Name name, Class clazz);

All of this methods end up invoking the catalog facade method:

getResourceByName(NamespaceInfo namespace, String name, Class clazz);

When no NameSpaceInfo is provided (case 1 and 3) the NameSpaceInfo will be searched or by the workspace name or by the name space URI:
https://github.com/geoserver/geoserver/blob/master/src/main/src/main/java/org/geoserver/catalog/impl/CatalogImpl.java#L441-L461

And this is where the one to one relationship between workspaces and schema name spaces comes in. If multiple workspaces had the same URI when searching a NameSpaceInfo by the URI we will end up with multiple NameSpaceInfo with different prefix (workspaces names).

Dis I mis anything here ?

A possible solution to allow several workspaces to share the same name space is the concept of isolated workspaces. Resources of isolated workspaces can only be used\accessed in the context of virtual services for that workspace but isolated workspaces can have the same URI of other workspaces (isolated or not). When looking for a NameSpaceInfo by the URI two situations can happen:

  • if we are in the context of virtual service and the local workspace URI match the desired URI we return the NameSpaceInfo associated to our workspace, otherwise we perform a normal search ignoring all the others isolated workspaces;

  • if we are not in the context of a virtual service we perform a normal search ignoring all the isolated workspaces;

The new isolated workspaces logic can be implemented in the already existing LocalWorkspace catalog wrapper.

Isolated workspaces will allow the same feature type to be published several times in different workspaces.

Opinions on this ?

Regards,

Nuno Oliveira

···
-- 
==
GeoServer Professional Services from the experts! 
Visit [http://goo.gl/it488V](http://goo.gl/it488V) for more information.
==
Nuno Miguel Carvalho Oliveira
@nmcoliveira
Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054  Massarosa (LU)
Italy

phone: +39 0584 962313
fax:   +39 0584 1660272
mob:   +39  333 8128928

[http://www.geo-solutions.it](http://www.geo-solutions.it)
[http://twitter.com/geosolutions_it](http://twitter.com/geosolutions_it)

-------------------------------------------------------

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono
da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate
nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e
-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo
anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.
 
The information in this message and/or attachments, is intended solely for the attention and use of
the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree
June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying,
distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender does not give any warranty or accept liability as the content,
accuracy or completeness of sent messages and accepts no responsibility  for changes made after they were sent or for other risks which
arise as a result of e-mail transmission, viruses, etc.

Nuno,

have you considered going further and allowing each workspace to contain layers with different namespaces? Each workspace might have a default namespace, just like the global workspace, to aid backwards compatibility.

One additional change would be for each namespace to be configured with a namespace prefix as it would no longer be sufficient to take the name of the enclosing workspace, because each workspace could contain layers with different namespaces.

Are workspaces and layers orthogonal concerns? Should a single layer be able to be published through multiple workspaces? This is the inverse of your use-case (multiple layers with the same feature type). Should workspaces be containers for layers or only containers for services? That is, should workspaces be like folders that own their contents, or should they be like a Eclipse workspaces that do not? (Attributes versus associations.)

The use-cases that must be considered are not only publishing the same type more than once for app-schema, but workspace and layer access control. The users list has seen those with one workspace per client. This pattern is unusable for app-schema.

I do not think that you have addressed the problem of an app-schema type-instance A which has a nested type-instance B from a different namespace. Would chaining of B be resolved in the same workspace first? This would suggest that A and B would both have to be in one workspace only. B might also be public.

I have been using the term "layer" to mean a thing with data, and "type-instance" is I think pretty much the same thing: an instance of a feature type that is connected to some data. I do not want to use "type" by itself as we are considering making it non-unique.

Apologies for the scope creep, but you are scratching the surface of a deeper problem.

Other rats in the app-schema wood-pile are (1) the static singleton AppSchemaDataAccessRegistry, which knows each data access by its type only, not its workspace, and (2) the feature type cache, which assumes that types are equal if their names are equal. We have (2) because types in GML 3.2 and application schemas in general are cyclic graphs not trees so you cannot implement Object.equals for types by recursion (an instance of <https://en.wikipedia.org/wiki/Graph_isomorphism_problem&gt;\). What (2) means for you is that, if you want to publish two feature types with the same qualified name but from different incompatible versions of a schema, you might need a workspace-local feature type cache. Current rule is that we do not support more than one version of each schema in each GeoServer instance; I think we should keep this rule.

Stop me now, I am just getting started! :wink:

Kind regards,
Ben.

On 10/02/17 13:22, Nuno Oliveira wrote:

Hi,

The main use case for this is to allow the publishing of the same
feature type in different virtual services, this is particularity
important for complex features (app-schema). Sometimes we want to map
the same feature type in a different way and publish it in different end
points (virtual services). Because a feature type is associated with a
specific name space and name spaces have a one to one relationship with
workspaces, the only way to this right now is to use several GeoServer
instances.

When dealing with simple features or complex features there is two
different feature types concepts to take in account, one is the feature
type know by GeoTools (FeatureType) and the other one is the feature
type known by GeoServer (FeatureTypeInfo). The link between a GeoTools
feature type and a GeoServer feature type is the name. The name is
composed by a name space and the type name, for example
"http://www.census.gov:tiger_roads". This link needs to be used for
example when encoding features in WFS.

In GeoServer, workspaces have a name and a name space. When a resource
is created it inherits is workspace name space. For example, if we
create a workspace named tiger with name space (URI)
http://www.census.gov and create a vector layer named tiger_roads inside
the tiger workspace, the layer feature type (FeatureTypeInfo) name will
be "http://www.census.gov:tiger_roads". The link needed between GeoTools
and GeoServer feature types described above is the main reason for the
one to one relationship limitation between workspaces and name spaces,
for WFS there is no workspaces only name spaces.

Did I understood this relationships correctly so far ?

More in detail, when creating an workspace in GeoServer two objects are
actually created: the WorkspaceInfo and a NameSpaceInfo. The first
object contains basically the workspace name and the second object
contains the workspace name (prefix) and the workspace name space (URI).

At the lowest level in GeoServer resources are searched by the
NameSpaceInfo ID and the resource name. The catalog API give us three
ways to lookup for resources by their name:

    1. getResourceByName(String ns, String name, Class<T> clazz);
    2. getResourceByName(NamespaceInfo ns, String name, Class<T> clazz);
    3. getResourceByName(Name name, Class<T> clazz);

All of this methods end up invoking the catalog facade method:

    getResourceByName(NamespaceInfo namespace, String name, Class<T>
clazz);

When no NameSpaceInfo is provided (case 1 and 3) the NameSpaceInfo will
be searched or by the workspace name or by the name space URI:
https://github.com/geoserver/geoserver/blob/master/src/main/src/main/java/org/geoserver/catalog/impl/CatalogImpl.java#L441-L461

<https://github.com/geoserver/geoserver/blob/master/src/main/src/main/java/org/geoserver/catalog/impl/CatalogImpl.java#L441-L461&gt;And
this is where the one to one relationship between workspaces and schema
name spaces comes in. If multiple workspaces had the same URI when
searching a NameSpaceInfo by the URI we will end up with multiple
NameSpaceInfo with different prefix (workspaces names).

Dis I mis anything here ?

A possible solution to allow several workspaces to share the same name
space is the concept of isolated workspaces. Resources of isolated
workspaces can only be used\accessed in the context of virtual services
for that workspace but isolated workspaces can have the same URI of
other workspaces (isolated or not). When looking for a NameSpaceInfo by
the URI two situations can happen:

    - if we are in the context of virtual service and the local
workspace URI match the desired URI we return the NameSpaceInfo
associated to our workspace, otherwise we perform a normal search
ignoring all the others isolated workspaces;

    - if we are not in the context of a virtual service we perform a
normal search ignoring all the isolated workspaces;

The new isolated workspaces logic can be implemented in the already
existing LocalWorkspace catalog wrapper.

Isolated workspaces will allow the same feature type to be published
several times in different workspaces.

Opinions on this ?

Regards,

Nuno Oliveira

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot

_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

--
Ben Caradoc-Davies <ben@anonymised.com>
Director
Transient Software Limited <http://transient.nz/&gt;
New Zealand

Hi Ben,

| Stop me now, I am just getting started!

Ahaha thanks for the detailed feedback :slight_smile:

Long story short, I know the deeper problem but I (we) can't afford the perfect solution. The solution I proposed is not perfect and will certainly not fix all the current problems between app-schema and workspaces but will allow users to publish the same feature type multiple times (this is not an app-schema exclusive issue) and avoid having several GeoServer instances just for that propose.

In a strict GeoServer point view isolated workspaces can repeat name spaces and will make their resources only available in their scope and will give preference to their own resources when looking for a certain resource. The consequence of this is that it will be possible to publish the same feature type (name space + name) multiple times.

For GeoServer app-schema is a normal data store and app-schema on is side doesn't know anything about GeoServer workspaces. The problem on app-schema side is that mappings are no considered by store but instead globally, the main reason for this was feature chaining right ? So when we search the mappings for a certain feature type (XML element) the AppSchemaDataAccessRegistry singleton will look in all the defined app-schema stores and return the first one he founds.

An app-schema data store can contain mappings for multiple types right ? So I propose to change the AppSchemaDataAccessRegistry in sort that he will give preference to mappings defined in the same store and only if the desired mapping is not found in the same store we will search globally. This way it will be possible to define different mappings for a feature type (XML element) and publish them in GeoServer in isolated workspaces.

What do you think about this ?

Regards,

On 02/10/2017 02:32 AM, Ben Caradoc-Davies wrote:

Nuno,

have you considered going further and allowing each workspace to contain layers with different namespaces? Each workspace might have a default namespace, just like the global workspace, to aid backwards compatibility.

One additional change would be for each namespace to be configured with a namespace prefix as it would no longer be sufficient to take the name of the enclosing workspace, because each workspace could contain layers with different namespaces.

Are workspaces and layers orthogonal concerns? Should a single layer be able to be published through multiple workspaces? This is the inverse of your use-case (multiple layers with the same feature type). Should workspaces be containers for layers or only containers for services? That is, should workspaces be like folders that own their contents, or should they be like a Eclipse workspaces that do not? (Attributes versus associations.)

The use-cases that must be considered are not only publishing the same type more than once for app-schema, but workspace and layer access control. The users list has seen those with one workspace per client. This pattern is unusable for app-schema.

I do not think that you have addressed the problem of an app-schema type-instance A which has a nested type-instance B from a different namespace. Would chaining of B be resolved in the same workspace first? This would suggest that A and B would both have to be in one workspace only. B might also be public.

I have been using the term "layer" to mean a thing with data, and "type-instance" is I think pretty much the same thing: an instance of a feature type that is connected to some data. I do not want to use "type" by itself as we are considering making it non-unique.

Apologies for the scope creep, but you are scratching the surface of a deeper problem.

Other rats in the app-schema wood-pile are (1) the static singleton AppSchemaDataAccessRegistry, which knows each data access by its type only, not its workspace, and (2) the feature type cache, which assumes that types are equal if their names are equal. We have (2) because types in GML 3.2 and application schemas in general are cyclic graphs not trees so you cannot implement Object.equals for types by recursion (an instance of <https://en.wikipedia.org/wiki/Graph_isomorphism_problem&gt;\). What (2) means for you is that, if you want to publish two feature types with the same qualified name but from different incompatible versions of a schema, you might need a workspace-local feature type cache. Current rule is that we do not support more than one version of each schema in each GeoServer instance; I think we should keep this rule.

Stop me now, I am just getting started! :wink:

Kind regards,
Ben.

On 10/02/17 13:22, Nuno Oliveira wrote:

Hi,

The main use case for this is to allow the publishing of the same
feature type in different virtual services, this is particularity
important for complex features (app-schema). Sometimes we want to map
the same feature type in a different way and publish it in different end
points (virtual services). Because a feature type is associated with a
specific name space and name spaces have a one to one relationship with
workspaces, the only way to this right now is to use several GeoServer
instances.

When dealing with simple features or complex features there is two
different feature types concepts to take in account, one is the feature
type know by GeoTools (FeatureType) and the other one is the feature
type known by GeoServer (FeatureTypeInfo). The link between a GeoTools
feature type and a GeoServer feature type is the name. The name is
composed by a name space and the type name, for example
"http://www.census.gov:tiger_roads". This link needs to be used for
example when encoding features in WFS.

In GeoServer, workspaces have a name and a name space. When a resource
is created it inherits is workspace name space. For example, if we
create a workspace named tiger with name space (URI)
http://www.census.gov and create a vector layer named tiger_roads inside
the tiger workspace, the layer feature type (FeatureTypeInfo) name will
be "http://www.census.gov:tiger_roads". The link needed between GeoTools
and GeoServer feature types described above is the main reason for the
one to one relationship limitation between workspaces and name spaces,
for WFS there is no workspaces only name spaces.

Did I understood this relationships correctly so far ?

More in detail, when creating an workspace in GeoServer two objects are
actually created: the WorkspaceInfo and a NameSpaceInfo. The first
object contains basically the workspace name and the second object
contains the workspace name (prefix) and the workspace name space (URI).

At the lowest level in GeoServer resources are searched by the
NameSpaceInfo ID and the resource name. The catalog API give us three
ways to lookup for resources by their name:

    1. getResourceByName(String ns, String name, Class<T> clazz);
    2. getResourceByName(NamespaceInfo ns, String name, Class<T> clazz);
    3. getResourceByName(Name name, Class<T> clazz);

All of this methods end up invoking the catalog facade method:

    getResourceByName(NamespaceInfo namespace, String name, Class<T>
clazz);

When no NameSpaceInfo is provided (case 1 and 3) the NameSpaceInfo will
be searched or by the workspace name or by the name space URI:
https://github.com/geoserver/geoserver/blob/master/src/main/src/main/java/org/geoserver/catalog/impl/CatalogImpl.java#L441-L461

<https://github.com/geoserver/geoserver/blob/master/src/main/src/main/java/org/geoserver/catalog/impl/CatalogImpl.java#L441-L461&gt;And

this is where the one to one relationship between workspaces and schema
name spaces comes in. If multiple workspaces had the same URI when
searching a NameSpaceInfo by the URI we will end up with multiple
NameSpaceInfo with different prefix (workspaces names).

Dis I mis anything here ?

A possible solution to allow several workspaces to share the same name
space is the concept of isolated workspaces. Resources of isolated
workspaces can only be used\accessed in the context of virtual services
for that workspace but isolated workspaces can have the same URI of
other workspaces (isolated or not). When looking for a NameSpaceInfo by
the URI two situations can happen:

    - if we are in the context of virtual service and the local
workspace URI match the desired URI we return the NameSpaceInfo
associated to our workspace, otherwise we perform a normal search
ignoring all the others isolated workspaces;

    - if we are not in the context of a virtual service we perform a
normal search ignoring all the isolated workspaces;

The new isolated workspaces logic can be implemented in the already
existing LocalWorkspace catalog wrapper.

Isolated workspaces will allow the same feature type to be published
several times in different workspaces.

Opinions on this ?

Regards,

Nuno Oliveira

------------------------------------------------------------------------------

Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot

_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

--

GeoServer Professional Services from the experts!
Visit http://goo.gl/it488V for more information.

Nuno Miguel Carvalho Oliveira
@nmcoliveira
Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 333 8128928

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono
da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate
nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e
-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo
anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.
  The information in this message and/or attachments, is intended solely for the attention and use of
the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree
June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying,
distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender does not give any warranty or accept liability as the content,
accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which
arise as a result of e-mail transmission, viruses, etc.

Nuno,

I accept that a full namespace/workspace information model refactoring is too expensive. It would also be backwards-incompatible for all users; I think this is not justified for a change that would benefit only app-schema users. I am comfortable with your more modest improvement.

Yes, an app-schema store can contain multiple mapping for the same type:
http://docs.geoserver.org/latest/en/user/data/app-schema/feature-chaining.html#multiple-mappings-of-the-same-type

If the isolated feature type is not visible at the top level and is only published as a nested type, could it be mapped entirely using the nested mapping mechanism, without any changes to workspaces? What functionality would isolated workspaces provide that cannot be delivered with nested mappings? Your original email contains the answer: delivering the same type more than once via virtual services.

This sounds like a useful improvement, and your approach seems reasonable. It will be tricky to test that there is no unintended cross-communication between the isolated workspaces.

Kind regards,
Ben.

On 11/02/17 04:19, Nuno Oliveira wrote:

Hi Ben,

| Stop me now, I am just getting started!

Ahaha thanks for the detailed feedback :slight_smile:

Long story short, I know the deeper problem but I (we) can't afford the
perfect solution. The solution I proposed is not perfect and will
certainly not fix all the current problems between app-schema and
workspaces but will allow users to publish the same feature type
multiple times (this is not an app-schema exclusive issue) and avoid
having several GeoServer instances just for that propose.

In a strict GeoServer point view isolated workspaces can repeat name
spaces and will make their resources only available in their scope and
will give preference to their own resources when looking for a certain
resource. The consequence of this is that it will be possible to publish
the same feature type (name space + name) multiple times.

For GeoServer app-schema is a normal data store and app-schema on is
side doesn't know anything about GeoServer workspaces. The problem on
app-schema side is that mappings are no considered by store but instead
globally, the main reason for this was feature chaining right ? So when
we search the mappings for a certain feature type (XML element) the
AppSchemaDataAccessRegistry singleton will look in all the defined
app-schema stores and return the first one he founds.

An app-schema data store can contain mappings for multiple types right ?
So I propose to change the AppSchemaDataAccessRegistry in sort that he
will give preference to mappings defined in the same store and only if
the desired mapping is not found in the same store we will search
globally. This way it will be possible to define different mappings for
a feature type (XML element) and publish them in GeoServer in isolated
workspaces.

What do you think about this ?

--
Ben Caradoc-Davies <ben@anonymised.com>
Director
Transient Software Limited <http://transient.nz/&gt;
New Zealand

Hi Ben,

Thanks for the feedback.

| It will be tricky to test that there is no unintended cross-communication between the isolated workspaces.

Yeah I agree this will b tricky to test.

Kind regards,

Nuno Oliveira

On 02/12/2017 11:06 PM, Ben Caradoc-Davies wrote:

Nuno,

I accept that a full namespace/workspace information model refactoring is too expensive. It would also be backwards-incompatible for all users; I think this is not justified for a change that would benefit only app-schema users. I am comfortable with your more modest improvement.

Yes, an app-schema store can contain multiple mapping for the same type:
http://docs.geoserver.org/latest/en/user/data/app-schema/feature-chaining.html#multiple-mappings-of-the-same-type

If the isolated feature type is not visible at the top level and is only published as a nested type, could it be mapped entirely using the nested mapping mechanism, without any changes to workspaces? What functionality would isolated workspaces provide that cannot be delivered with nested mappings? Your original email contains the answer: delivering the same type more than once via virtual services.

This sounds like a useful improvement, and your approach seems reasonable. It will be tricky to test that there is no unintended cross-communication between the isolated workspaces.

Kind regards,
Ben.

On 11/02/17 04:19, Nuno Oliveira wrote:

Hi Ben,

| Stop me now, I am just getting started!

Ahaha thanks for the detailed feedback :slight_smile:

Long story short, I know the deeper problem but I (we) can't afford the
perfect solution. The solution I proposed is not perfect and will
certainly not fix all the current problems between app-schema and
workspaces but will allow users to publish the same feature type
multiple times (this is not an app-schema exclusive issue) and avoid
having several GeoServer instances just for that propose.

In a strict GeoServer point view isolated workspaces can repeat name
spaces and will make their resources only available in their scope and
will give preference to their own resources when looking for a certain
resource. The consequence of this is that it will be possible to publish
the same feature type (name space + name) multiple times.

For GeoServer app-schema is a normal data store and app-schema on is
side doesn't know anything about GeoServer workspaces. The problem on
app-schema side is that mappings are no considered by store but instead
globally, the main reason for this was feature chaining right ? So when
we search the mappings for a certain feature type (XML element) the
AppSchemaDataAccessRegistry singleton will look in all the defined
app-schema stores and return the first one he founds.

An app-schema data store can contain mappings for multiple types right ?
So I propose to change the AppSchemaDataAccessRegistry in sort that he
will give preference to mappings defined in the same store and only if
the desired mapping is not found in the same store we will search
globally. This way it will be possible to define different mappings for
a feature type (XML element) and publish them in GeoServer in isolated
workspaces.

What do you think about this ?

--

GeoServer Professional Services from the experts!
Visit http://goo.gl/it488V for more information.

Nuno Miguel Carvalho Oliveira
@nmcoliveira
Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 333 8128928

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono
da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate
nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e
-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo
anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.
  The information in this message and/or attachments, is intended solely for the attention and use of
the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree
June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying,
distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender does not give any warranty or accept liability as the content,
accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which
arise as a result of e-mail transmission, viruses, etc.

I am concerned that if we do let multiple workspaces have the same namespace we will break the default DescribeFeatureType behaviour which assumes it can reply on namespace to keep name collisions out of the generated GML. If this is not the case we may need to check for conflict and modify the name during publishing …

This feels like a pretty fundamental part of GeoServer WFS to be changing.

···

On 9 February 2017 at 16:22, Nuno Oliveira <nuno.oliveira@anonymised.com> wrote:

Hi,

The main use case for this is to allow the publishing of the same feature type in different virtual services, this is particularity important for complex features (app-schema). Sometimes we want to map the same feature type in a different way and publish it in different end points (virtual services). Because a feature type is associated with a specific name space and name spaces have a one to one relationship with workspaces, the only way to this right now is to use several GeoServer instances.

When dealing with simple features or complex features there is two different feature types concepts to take in account, one is the feature type know by GeoTools (FeatureType) and the other one is the feature type known by GeoServer (FeatureTypeInfo). The link between a GeoTools feature type and a GeoServer feature type is the name. The name is composed by a name space and the type name, for example “http://www.census.gov:tiger_roads”. This link needs to be used for example when encoding features in WFS.

In GeoServer, workspaces have a name and a name space. When a resource is created it inherits is workspace name space. For example, if we create a workspace named tiger with name space (URI) http://www.census.gov and create a vector layer named tiger_roads inside the tiger workspace, the layer feature type (FeatureTypeInfo) name will be “http://www.census.gov:tiger_roads”. The link needed between GeoTools and GeoServer feature types described above is the main reason for the one to one relationship limitation between workspaces and name spaces, for WFS there is no workspaces only name spaces.

Did I understood this relationships correctly so far ?

More in detail, when creating an workspace in GeoServer two objects are actually created: the WorkspaceInfo and a NameSpaceInfo. The first object contains basically the workspace name and the second object contains the workspace name (prefix) and the workspace name space (URI).

At the lowest level in GeoServer resources are searched by the NameSpaceInfo ID and the resource name. The catalog API give us three ways to lookup for resources by their name:

  1. getResourceByName(String ns, String name, Class clazz);
  2. getResourceByName(NamespaceInfo ns, String name, Class clazz);
  3. getResourceByName(Name name, Class clazz);

All of this methods end up invoking the catalog facade method:

getResourceByName(NamespaceInfo namespace, String name, Class clazz);

When no NameSpaceInfo is provided (case 1 and 3) the NameSpaceInfo will be searched or by the workspace name or by the name space URI:
https://github.com/geoserver/geoserver/blob/master/src/main/src/main/java/org/geoserver/catalog/impl/CatalogImpl.java#L441-L461

And this is where the one to one relationship between workspaces and schema name spaces comes in. If multiple workspaces had the same URI when searching a NameSpaceInfo by the URI we will end up with multiple NameSpaceInfo with different prefix (workspaces names).

Dis I mis anything here ?

A possible solution to allow several workspaces to share the same name space is the concept of isolated workspaces. Resources of isolated workspaces can only be used\accessed in the context of virtual services for that workspace but isolated workspaces can have the same URI of other workspaces (isolated or not). When looking for a NameSpaceInfo by the URI two situations can happen:

  • if we are in the context of virtual service and the local workspace URI match the desired URI we return the NameSpaceInfo associated to our workspace, otherwise we perform a normal search ignoring all the others isolated workspaces;

  • if we are not in the context of a virtual service we perform a normal search ignoring all the isolated workspaces;

The new isolated workspaces logic can be implemented in the already existing LocalWorkspace catalog wrapper.

Isolated workspaces will allow the same feature type to be published several times in different workspaces.

Opinions on this ?

Regards,

Nuno Oliveira

-- 
==
GeoServer Professional Services from the experts! 
Visit [http://goo.gl/it488V](http://goo.gl/it488V) for more information.
==
Nuno Miguel Carvalho Oliveira
@nmcoliveira
Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054  Massarosa (LU)
Italy

phone: +39 0584 962313
fax:   +39 0584 1660272
mob:   +39  333 8128928

[http://www.geo-solutions.it](http://www.geo-solutions.it)
[http://twitter.com/geosolutions_it](http://twitter.com/geosolutions_it)

-------------------------------------------------------

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono
da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate
nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e
-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo
anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.
 
The information in this message and/or attachments, is intended solely for the attention and use of
the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree
June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying,
distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender does not give any warranty or accept liability as the content,
accuracy or completeness of sent messages and accepts no responsibility  for changes made after they were sent or for other risks which
arise as a result of e-mail transmission, viruses, etc.

Check out the vibrant tech community on one of the world’s most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot


Geoserver-devel mailing list
Geoserver-devel@anonymised.com.366…sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel


Jody Garnett

I know this is chiming in late but I can say that the whole concept of a workspace was introduced so that we could de-couple it from the idea of a WFS namespace, having the former be a layer grouping concept and the latter being just an attribute of a layer, meaning no problem to share them amongst workspaces.

That said, practically speaking Jody is correct and there is a bunch of logic that has built up over time that relies on namespace as a grouping concept so it will be interesting to see how hard those ties are to break.

···


Jody Garnett

On 9 February 2017 at 16:22, Nuno Oliveira <nuno.oliveira@anonymised.com> wrote:

Hi,

The main use case for this is to allow the publishing of the same feature type in different virtual services, this is particularity important for complex features (app-schema). Sometimes we want to map the same feature type in a different way and publish it in different end points (virtual services). Because a feature type is associated with a specific name space and name spaces have a one to one relationship with workspaces, the only way to this right now is to use several GeoServer instances.

When dealing with simple features or complex features there is two different feature types concepts to take in account, one is the feature type know by GeoTools (FeatureType) and the other one is the feature type known by GeoServer (FeatureTypeInfo). The link between a GeoTools feature type and a GeoServer feature type is the name. The name is composed by a name space and the type name, for example “http://www.census.gov:tiger_roads”. This link needs to be used for example when encoding features in WFS.

In GeoServer, workspaces have a name and a name space. When a resource is created it inherits is workspace name space. For example, if we create a workspace named tiger with name space (URI) http://www.census.gov and create a vector layer named tiger_roads inside the tiger workspace, the layer feature type (FeatureTypeInfo) name will be “http://www.census.gov:tiger_roads”. The link needed between GeoTools and GeoServer feature types described above is the main reason for the one to one relationship limitation between workspaces and name spaces, for WFS there is no workspaces only name spaces.

Did I understood this relationships correctly so far ?

More in detail, when creating an workspace in GeoServer two objects are actually created: the WorkspaceInfo and a NameSpaceInfo. The first object contains basically the workspace name and the second object contains the workspace name (prefix) and the workspace name space (URI).

At the lowest level in GeoServer resources are searched by the NameSpaceInfo ID and the resource name. The catalog API give us three ways to lookup for resources by their name:

  1. getResourceByName(String ns, String name, Class clazz);
  2. getResourceByName(NamespaceInfo ns, String name, Class clazz);
  3. getResourceByName(Name name, Class clazz);

All of this methods end up invoking the catalog facade method:

getResourceByName(NamespaceInfo namespace, String name, Class clazz);

When no NameSpaceInfo is provided (case 1 and 3) the NameSpaceInfo will be searched or by the workspace name or by the name space URI:
https://github.com/geoserver/geoserver/blob/master/src/main/src/main/java/org/geoserver/catalog/impl/CatalogImpl.java#L441-L461

And this is where the one to one relationship between workspaces and schema name spaces comes in. If multiple workspaces had the same URI when searching a NameSpaceInfo by the URI we will end up with multiple NameSpaceInfo with different prefix (workspaces names).

Dis I mis anything here ?

A possible solution to allow several workspaces to share the same name space is the concept of isolated workspaces. Resources of isolated workspaces can only be used\accessed in the context of virtual services for that workspace but isolated workspaces can have the same URI of other workspaces (isolated or not). When looking for a NameSpaceInfo by the URI two situations can happen:

  • if we are in the context of virtual service and the local workspace URI match the desired URI we return the NameSpaceInfo associated to our workspace, otherwise we perform a normal search ignoring all the others isolated workspaces;

  • if we are not in the context of a virtual service we perform a normal search ignoring all the isolated workspaces;

The new isolated workspaces logic can be implemented in the already existing LocalWorkspace catalog wrapper.

Isolated workspaces will allow the same feature type to be published several times in different workspaces.

Opinions on this ?

Regards,

Nuno Oliveira

-- 
==
GeoServer Professional Services from the experts! 
Visit [http://goo.gl/it488V](http://goo.gl/it488V) for more information.
==
Nuno Miguel Carvalho Oliveira
@nmcoliveira
Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054  Massarosa (LU)
Italy

phone: +39 0584 962313
fax:   +39 0584 1660272
mob:   +39  333 8128928

[http://www.geo-solutions.it](http://www.geo-solutions.it)
[http://twitter.com/geosolutions_it](http://twitter.com/geosolutions_it)

-------------------------------------------------------

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono
da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate
nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e
-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo
anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.
 
The information in this message and/or attachments, is intended solely for the attention and use of
the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree
June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying,
distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender does not give any warranty or accept liability as the content,
accuracy or completeness of sent messages and accepts no responsibility  for changes made after they were sent or for other risks which
arise as a result of e-mail transmission, viruses, etc.

Check out the vibrant tech community on one of the world’s most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot


Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Hello everybody,

Looking at Snowflake GoPublisher WFS that does not have these problems to
deliver INSPIRE compliant WFS, there, the "workspace" is not linked to a
single XSD schema.

For a reason that we cant understand, in Geoserver the name of the workspace
is inherited from the name of the XSD file. For complex features this does
not make sense, as a complex feature is based on multiple feature types, and
therefore on multiple XSD files.

For example, in order to provide access to ps:ProtectedSite feature type, in
Geoserver, three workspaces need to be created, ps for ps.XSD, base for
base.XSD and gn for gn.XSD. But in reality in order to provide access to a
single complex featureType, ps:ProtectedSite, from the user perspective it
should be only one workspace, considering that ps:ProtectedSite that is a
dataset.

Therefore from an INSPIRE data provider perspective that need to provide
access to complex features, the Geoserver wokspace is not actually a
workspace, but an XSD schema holder. From the INSPIRE data provider
perspective the "workspace" is actually the Geoserver instance and the
geoserver workspaces are just used for holding XSDs.

While working with Snowflake GoPublisherWFS we found that the software do
not have such an approach of workspaces. In a GoPublisherWFS instance can be
loaded as many XSD files as necessary to provide access to a dataset. Even
more there are no problems to provide access to a dataset that has more than
one featureType. We can say that in GoPublisherWFS one instance = one
workspace based on multiple XSD files.

With GoPublisherWFS it is possible to provide access to a dataset that
contains more than one featureType. We tried to do the same in Geoserver,
but we found that this approach with workspaces based on a single XSD schema
are generating issues that are not present in GoPublisherWFS.

We tested in Geoserver 2.12-beta as this bug
https://osgeo-org.atlassian.net/browse/GEOS-4773 was closed in this version.

1. For example a GetPropertyValue request to retrieve the geographical name
of a protected site will return null namespace prefixes in the GML.

Link to test nulls:
http://inspire.teamnet.ro/geoserver/wfs?version=2.0.0&request=GetPropertyValue&typeName=ps:ProtectedSite&valueReference=ps:siteName/gn:GeographicalName/gn:spelling/gn:SpellingOfName&count=2

2. Another example is related to GetSpatialDataSet StoredQuerry that is
providing null namespace prefixes while retrieving a dataset with multiple
featureTypes. In practice a dataset contains more than one featureType from
multiple data themes, all having the same metadata and having the geometries
in topology and being produced at the same precision and having the same
lineage. The request is providing a dataset with protected sites,
administrative units, bio-geographical regions and their corresponding
geographical names, but there are null namespaces.

Link to test nulls:
http://inspire.teamnet.ro/geoserver/wfs?request=GetFeature&StoredQueryID=http://inspire.ec.europa.eu/operation/download/GetSpatialDataSet&version=2.0.0&crs=epsg:3035&count=1

3. Even if we do not intend to use virtual services unless they will be
linked to a dataset, a GetFeature request to a virtual service (in this case
"ps") are returning null namespace prefixes in the retrieved GML. This means
that virtual services cant be used as endpoints, in order to allow a single
instance of Geoserver to be used with multiple endpoints in the case that a
data provider has one featureType per dataset. Other software is able to
create separate endpoints per each dataset even if the dataset has more than
one featureType.

Link to test nulls
http://inspire.teamnet.ro/geoserver/ps/wfs?request=GetFeature&version=2.0.0&typeNames=ps:ProtectedSite&count=2

Therefore maybe the current workspaces in Geoserver should not be named
workspaces in the context of complex features or the so called workspaces
need to be redesigned. It looks like Geoserver should make a shift from flat
data to many-to many related data, simillar to the shift from shp to gdb or
from xls to mdb.

From an INSPIRE data provider perspective a workspace is tight to a dataset.

A dataset can contain more than one complex feature type so a dataset is
based on more than one XSD schema and more than one featureType. A dataset
is similar to a "feature dataset" in ArcGIS that contains "feature classes"
that are simmilar to featureTypes.

If a single instance of Geoserver would be able to provide access to a
single dataset, than workspaces do not make sense from INSPIRE perspective
as thy are not acttualy workspaces for complex features.

If a single instance of Geoserver would be able to provide access to more
datasets, then one workspace may be linked to the one dataset based on
multiple featureTypes and therefore on multiple XSD schemas. As INSPIRE
requires datasets to be accessible at a unique endpoint, virtual services
for such workspaces make sense.

We came as well to the conclusion that with the current Geoserver
configuration WFS and WMS should be accessible from different endpoints and
even from different Geoserver instances, but this is another subject, maybe
to be further discussed and it is linked to poor performance of rendering
images based on complex features, so flat simple features are used for WMS.
The link between WMS and WFS features is ensured trough short URL, such as
http://inspire.teamnet.ro/ENV/PADS/psPS/RONPA0022

Best regards,
Iurie Maxim
Teamnet, Romania

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Allowing-multiple-workspaces-to-use-the-same-name-space-URI-tp5307302p5318092.html
Sent from the GeoServer - Dev mailing list archive at Nabble.com.