# HG changeset patch # User Christian Lins # Date 1361789477 -3600 # Node ID cbfdd737600946da1378b985b767cbeee6b69073 # Parent cc50e1b9fc6062e20b393cb5f3a1af31202a16f1 ArtifactMapfileGenerator can now generate user shape mapfiles again. diff -r cc50e1b9fc60 -r cbfdd7376009 flys-artifacts/src/main/java/de/intevation/flys/mapserver/ArtifactMapfileGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/mapserver/ArtifactMapfileGenerator.java Wed Feb 20 21:00:33 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/mapserver/ArtifactMapfileGenerator.java Mon Feb 25 11:51:17 2013 +0100 @@ -64,7 +64,10 @@ } else if (fileName.startsWith(MS_PREFIX_USER)) { - createUserShapeLayer(layerShape); + File userLayer = createUserShapeLayer(layerShape); + if (userLayer != null) { + layerSnippets.add(userLayer.getCanonicalPath()); + } } else if (fileName.startsWith(MS_PREFIX_WSPLGEN)) { @@ -253,7 +256,7 @@ * Creates a layer file used for Mapserver's mapfile which represents the * shape files uploaded by the user. */ - protected void createUserShapeLayer(File file) + protected File createUserShapeLayer(File file) throws FileNotFoundException, IOException { String uuid = uuidFromPath(file.getAbsolutePath()); @@ -264,7 +267,7 @@ if (!test.exists() || !test.canRead()) { logger.debug("No user layer existing."); - return; + return null; } File userShape = new File(dir, WSPLGEN_USER_SHAPE); @@ -284,7 +287,8 @@ info.setType("POLYGON"); } else { - return; + logger.debug("createUserShapeLayer(): unexpected geometry type"); + return null; } info.setDirectory(uuid); info.setData(WSPLGEN_USER_SHAPE); @@ -298,17 +302,19 @@ Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE); if (tpl == null) { logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found."); - return; + return null; } + File layerFile = new File(dir, nameUser); + try { - writeLayer(info, new File(dir, nameUser), tpl); + writeLayer(info, layerFile, tpl); } catch (FileNotFoundException fnfe) { logger.error(fnfe, fnfe); logger.warn("Unable to write layer: " + nameUser); } - + return layerFile; } diff -r cc50e1b9fc60 -r cbfdd7376009 flys-artifacts/src/main/java/de/intevation/flys/mapserver/MapfileGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/mapserver/MapfileGenerator.java Wed Feb 20 21:00:33 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/mapserver/MapfileGenerator.java Mon Feb 25 11:51:17 2013 +0100 @@ -240,6 +240,7 @@ File baseDir = getShapefileBaseDir(); File[] artifactDirs = baseDir.listFiles(); + logger.debug("getProjectDirs(): found " + artifactDirs.length + " project directories"); return artifactDirs; } @@ -257,9 +258,10 @@ File[] layerFiles = dir.listFiles(new FilenameFilter() { @Override public boolean accept(File directory, String name) { - return name.startsWith(MS_PREFIX_BARRIERS) || - name.startsWith(MS_PREFIX_USER) || - name.startsWith(MS_PREFIX_WSPLGEN); + return name.endsWith(".shp") && + (name.startsWith(MS_PREFIX_BARRIERS) || + name.startsWith(MS_PREFIX_USER) || + name.startsWith(MS_PREFIX_WSPLGEN)); } }); @@ -268,6 +270,7 @@ } } + logger.debug("searchForLayerShapes(): found " + shapes.size() + " shapefiles"); return shapes; }