Hi Gabriel, Seems like IsolatedCatalogFacade.getNamespaceByURI method is working as a filtered lookup (not isolated namespaces results in the mix).
If we return directly facade.getNamespaceByURI(uri) this could match an isolated namespace since in DefaultCatalogFacade.getNamespaceByURI(String) there isn't any filter for isolated NS URIs. Also IsolatedCatalogFacade.getNamespaceByURI method uses getLocalNamespace() for getting the current local virtual service Namespace (if an OWS request is in context) to make available the isolated namespace in the lookup. So it seems like IsolatedCatalogFacade class was designed to support both: OWS and not OWS scoped requests. Regards, Fernando Mino == GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Fernando Mino Software Engineer GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) Italy phone: +39 0584 962313 fax: +39 0584 1660272 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail. From "Gabriel Roldan" [email protected] To [email protected] Cc "Geoserver-devel" [email protected] Date Mon, 11 Nov 2019 20:06:43 -0300 Subject Re: [Geoserver-devel] Isolated namespace validation Hi Fernando, thanks for the explanation. My curiosity arose from IsolatedCatalogFacade.getNamespaceByURI showing up as a hotspot while doing some load testing for the REST config api, called by CatalogImpl.validate(). Then I thought I could guard the method as follows: public NamespaceInfo getNamespaceByURI(String uri) { if (Dispatcher.REQUEST.get() == null) { return facade.getNamespaceByURI(uri); } ..... Given my understanding was IsolatedCatalogFacade has nothing to do for non OWS requests. Would that be correct? I guess that means CatalogFacade.getNamespaceByURI() will have to know it oughta return only global namespaces instead of the first one it finds? On Thu, 7 Nov 2019 at 12:17, [email protected] <[email protected]> wrote: Hola Gabriel, The case you exposed about having same URI for one global workspace and several isolated ones is valid as stated on GSIP that introduced isolated workspaces: https://github.com/geoserver/geoserver/wiki/GSIP-165---Add-isolated-workspaces-concept-to-GeoServer The following situation will be valid: * Prefix: st1 Namespace: http://www.stations.org/1.0 Isolated: false * Prefix: st2 Namespace: http://www.stations.org/1.0 Isolated: true * Prefix: st3 Namespace: http://www.stations.org/1.0 Isolated: true But this one will not be a valid one: * Prefix: st1 Namespace: http://www.stations.org/1.0 Isolated: false * Prefix: st2 Namespace: http://www.stations.org/1.0 Isolated: false * Prefix: st3 Namespace: http://www.stations.org/1.0 Isolated: true Only one non isolated workspace can use a certain namespace. Also on method: IsolatedCatalogFacade.getNamespaceByURI(String) Only global namespace can be returned, isolated ones are avoided so only one global workspace should match the lookup: https://github.com/geoserver/geoserver/blob/290813cbc463e68459b7eb7d8e6b031b0e192657/src/main/src/main/java/org/geoserver/catalog/impl/IsolatedCatalogFacade.java#L347 Regards, Fernando Mino == GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Fernando Mino Software Engineer GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) Italy phone: +39 0584 962313 fax: +39 0584 1660272 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail. From "Gabriel Roldan" [email protected] To "Geoserver-devel" [email protected] Cc Date Sat, 2 Nov 2019 11:49:13 -0300 Subject Re: [Geoserver-devel] Isolated namespace validation Tested and indeed, there's a race condition the will leave you with an invalid configuration: - Have 3 workspaces with the same uri: ws1:http://example.com ws2:http://example.com ws3:http://example.com - Change the config of ws1 to isolated:false and save now, depending existing = getNamespaceByURI(namespace.getURI()); may return ws1, in which case the validation proceeds and lets you with ws1 being non isolated and the other two being isolated, but with the same ns uri. On Sat, 2 Nov 2019 at 11:38, Gabriel Roldan <[email protected]> wrote: Hey, stumbled upon this code in CatalogImpl.validate(NamespaceInfo) and there seems to be a bug: if (!namespace.isIsolated()) { // not an isolated namespace \ workplace so we need to check for duplicates existing = getNamespaceByURI(namespace.getURI()); if (existing != null && !existing.getId().equals(namespace.getId())) { throw new IllegalArgumentException( "Namespace with URI '" + namespace.getURI() + "' already exists."); } } It calls getNamespaceByURI(namespace.getURI()), but that will get you only one of the possible many (say you have multiple isolated workspaces with the same namespace URI) I think the following would be correct, provided my understanding is too: if (!namespace.isIsolated()) { // not an isolated namespace \ workplace so we need to check for duplicates List<NamespaceInfo> currentList = facade.getNamespacesByURI(namespace.getURI()); for (NamespaceInfo current : currentList) { if (!current.getId().equals(namespace.getId())) { throw new IllegalArgumentException( "Namespace with URI '" + namespace.getURI() + "' already exists."); } } } -- Gabriel Roldán -- Gabriel Roldán -- Gabriel Roldán
_______________________________________________ Geoserver-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geoserver-devel
