According to the GeoServer Catalog API/Javadoc for Catalog.getStoreByName(String workspaceName, String name, Class clazz):
> Returns the store with the specified name in the specified workspace.
>
> clazz is used to determine the implementation of StoreInfo which should be returned. An example which would return a data store.
>
> DataStoreInfo dataStore = catalog.getStore(“workspaceName”, “name”, DataStoreInfo.class);
>
> Type Parameters:
> <T>
> Parameters:
> workspaceName The name of the workspace containing the store. The name can be null or DEFAULT to identify the default workspace.
> name The name of the store. The name can be null or DEFAULT to retrieve the default store in the specified workspace.
> clazz The class of store to return.
> Returns:
> The store matching name, or null if no such store e xists.
However, if the name is null , you get a NullPointerExceptipion in DefaultCatalogFacade:
java.lang.NullPointerException
at org.geoserver.catalog.impl.DefaultCatalogFacade.getStoreByName(DefaultCatalogFacade.java:181)
at org.geoserver.catalog.impl.CatalogImpl.getStoreByName(CatalogImpl.java:248)
at org.geoserver.catalog.impl.CatalogImpl.getStoreByName(CatalogImpl.java:233)
at org.geoserver.security.SecureCatalogImpl.getStoreByName(SecureCatalogImpl.java:418)
at org.geoserver.catalog.impl.AbstractFilteredCatalog.getStoreByName(AbstractFilteredCatalog.java:340)
at org.geoserver.catalog.impl.AbstractCatalogDecorator.getStoreByName(AbstractCatalogDecorator.java:105)
at org.geoserver.rest.util.RESTUtils.loadMapfromStore(RESTUtils.java:489)
at org.geoserver.rest.util.RESTUtils.getItem(RESTUtils.java:456)
at org.geoserver.rest.util.RESTUtils.getRootDirectory(RESTUtils.java:556)
...
As written, the javadocs are also slightly ambiguous - Should we expect the default store when the store name is null , or should the method merely accept null as a value for the store name and return null in turn. Based on the implementation of getNamespaceByPrefix() , we expect null to return the default store.
Only getNamespaceByPrefix() getWorkspaceByName and getStoreByName() are expected to return the default when passed null . Other get___ByName() methods in Catalog /CatalogImpl do not document what happens if null is passed in for the name (but most likely fail with a NPE).
|