<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!--P{margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Hi!<br>
<br>
I'm trying to automatically create a map from given layernames.<br>
<br>
To do so, I've created a management command and put it under geonode/maps/management/commands/createmapfromlayers.py<br>
<br>
the code looks as follows (only important lines):<br>
def handle(self, *args, **options):<br>
from geonode.layers.models import Layer<br>
from geonode.maps.models import Map, MapLayer<br>
for l in options.get('layers').split(','):<br>
    layers.append(Layer.objects.get(typename=l))<br>
<br>
m = Map()<br>
m.create_from_layer_list(user, layers, title, abstract)<br>
m.save()<br>
<br>
<br>
The Result is,  that a map is created. Also the layers are added at least to table in the relation maps_maplayer, but are not shown in the map.<br>
<br>
In the relation map_maplayer, the attribute for ows_url, layer_params and source params are missing.<br>
<br>
>From the geoserver log (see at the end of the mail), I can see that the layer is not found, but the request shown from the geoserver DEBUG output seems to be correct.<br>
<br>
Do you have any Idea, of what I'm doing wrong?<br>
<br>
Or are there any alternative ways to programatically create maps?<br>
<br>
Thanks in Advance!<br>
<br>
Cheers,<br>
Steffen<br>
<br>
geoserver.log (shortened stack trace )<br>
<br>
<br>
<br>
06 Feb 11:02:15 DEBUG [org.geoserver.security] - AuthenticationCache has no entry for basic, admin:c2af47d79129047bda3f8a97a1f68464<br>
06 Feb 11:02:15 DEBUG [org.geoserver.security.rememberme.GeoServerTokenBasedRememberMeServices] - Did not send remember-me cookie (principal did not set parameter '_spring_security_remember_me')<br>
06 Feb 11:02:15 DEBUG [org.geoserver.security.rememberme.GeoServerTokenBasedRememberMeServices] - Remember-me login not requested.<br>
06 Feb 11:02:15 DEBUG [org.geoserver.security] - AuthenticationCache adding new entry for basic, admin:c2af47d79129047bda3f8a97a1f68464<br>
06 Feb 11:02:15 DEBUG [org.geoserver.security] - Cache entries #: 0<br>
06 Feb 11:02:15 DEBUG [org.geoserver.security] - AuthenticationCache added new entry for basic, admin:c2af47d79129047bda3f8a97a1f68464<br>
06 Feb 11:02:15 DEBUG [org.geoserver.security] - Cache entries #: 1<br>
06 Feb 11:02:15 DEBUG [org.geoserver.security.RESTfulPathBasedFilterInvocationDefinitionMap] - Converted URL to lowercase, from: '/rest/layers/geonode:punktwolke.xml'; to: '/rest/layers/geonode:punktwolke.xml'  and httpMethod= GET<br>
06 Feb 11:02:15 DEBUG [org.geoserver.security.RESTfulPathBasedFilterInvocationDefinitionMap] - ~~~~~~~~~~ antPath= /rest/process/batchdownload/download/* methodList= [GET]<br>
06 Feb 11:02:15 DEBUG [org.geoserver.security.RESTfulPathBasedFilterInvocationDefinitionMap] - Candidate is: '/rest/layers/geonode:punktwolke.xml'; antPath is /rest/process/batchdownload/download/*; matchedPath=false; matchedMethods=true<br>
06 Feb 11:02:15 DEBUG [org.geoserver.security.RESTfulPathBasedFilterInvocationDefinitionMap] - ~~~~~~~~~~ antPath= /** methodList= [GET]<br>
06 Feb 11:02:15 DEBUG [org.geoserver.security.RESTfulPathBasedFilterInvocationDefinitionMap] - Candidate is: '/rest/layers/geonode:punktwolke.xml'; antPath is /**; matchedPath=true; matchedMethods=true<br>
06 Feb 11:02:15 DEBUG [org.geoserver.security.RESTfulPathBasedFilterInvocationDefinitionMap] - returning ROLE_ADMINISTRATOR<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/rest/layers/geonode:punktwolke.xml]<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/rest/layers/geonode:punktwolke.xml]<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/rest/layers/geonode:punktwolke.xml]<br>
06 Feb 11:02:15 DEBUG [org.geoserver] - Thread 40 locking in mode READ<br>
06 Feb 11:02:15 DEBUG [org.geoserver] - Thread 40 got the lock in mode READ<br>
06 Feb 11:02:15 DEBUG [org.geoserver] - Thread 40 releasing the lock in mode READ<br>
06 Feb 11:02:15 DEBUG [org.geoserver.filters] - Compressing output for mimetype: application/xml<br>
06 Feb 11:02:15 DEBUG [org.geoserver.security.filter.GeoServerSecurityContextPersistenceFilter$1] - SecurityContextHolder now cleared, as request processing completed<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/wms/reflect]<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/wms/reflect]<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/wms/reflect]<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/wms/reflect]<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/wms/reflect]<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - Matching patterns for request [/wms/reflect] are [/wms/*]<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - URI Template variables for request [/wms/reflect] are {}<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - Mapping [/wms/reflect] to HandlerExecutionChain with handler [org.geoserver.ows.Dispatcher@3892d911] and 1 interceptor<br>
06 Feb 11:02:15 INFO [org.geoserver.wms] - <br>
Request: getServiceInfo<br>
06 Feb 11:02:15 ERROR [org.geoserver.ows] - <br>
org.geoserver.platform.ServiceException: Could not find layer geonode:punktwolke<br>
    at org.geoserver.wms.map.GetMapKvpRequestReader.parseLayers(GetMapKvpRequestReader.java:1325)<br>
    at org.geoserver.wms.map.GetMapKvpRequestReader.read(GetMapKvpRequestReader.java:231)<br>
    ...<br>
06 Feb 11:02:15 DEBUG [org.geoserver.filters] - Compressing output for mimetype: text/xml;charset=UTF-8<br>
06 Feb 11:02:15 DEBUG [org.geoserver.security.filter.GeoServerSecurityContextPersistenceFilter$1] - SecurityContextHolder now cleared, as request processing completed<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/wms/reflect]<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/wms/reflect]<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/wms/reflect]<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/wms/reflect]<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - No handler mapping found for [/wms/reflect]<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - Matching patterns for request [/wms/reflect] are [/wms/*]<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - URI Template variables for request [/wms/reflect] are {}<br>
06 Feb 11:02:15 DEBUG [org.geoserver.ows.OWSHandlerMapping] - Mapping [/wms/reflect] to HandlerExecutionChain with handler [org.geoserver.ows.Dispatcher@3892d911] and 1 interceptor<br>
06 Feb 11:02:15 INFO [org.geoserver.wms] - <br>
Request: getServiceInfo<br>
06 Feb 11:02:15 ERROR [org.geoserver.ows] - <br>
org.geoserver.platform.ServiceException: Could not find layer geonode:punktwolke<br>
    at org.geoserver.wms.map.GetMapKvpRequestReader.parseLayers(GetMapKvpRequestReader.java:1325)<br>
    at org.geoserver.wms.map.GetMapKvpRequestReader.read(GetMapKvpRequestReader.java:231)<br>
    ...<br>
</p>
</body>
</html>