Skip to content

Commit

Permalink
[GEOS-7011] WPS Download fails if there is the same SLD as Default an…
Browse files Browse the repository at this point in the history
…d Selected
  • Loading branch information
aaime committed May 8, 2015
1 parent ed9abaa commit 134c72f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 19 deletions.
Expand Up @@ -8,8 +8,8 @@
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;


Expand Down Expand Up @@ -277,31 +277,26 @@ static File findStyle(StyleInfo style) throws IOException {
* @throws IOException * @throws IOException
*/ */
static List<File> collectStyles(LayerInfo layerInfo) throws IOException { static List<File> collectStyles(LayerInfo layerInfo) throws IOException {
final List<File> styles = new ArrayList<File>(); final List<File> styleFiles = new ArrayList<File>();


if (LOGGER.isLoggable(Level.FINE)) { if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Searching for default style"); LOGGER.log(Level.FINE, "Searching for default style");
} }
// default style
final StyleInfo style = layerInfo.getDefaultStyle();
File styleFile = findStyle(style);
if (styleFile != null) {
styles.add(styleFile);
}


// other styles // collect in a set to avoid duplicates (the styles can contain a copy of the
if (LOGGER.isLoggable(Level.FINE)) { // default style)
LOGGER.log(Level.FINE, "Searching for other styles"); LinkedHashSet<StyleInfo> styles = new LinkedHashSet<>();
styles.add(layerInfo.getDefaultStyle());
if (layerInfo.getStyles() != null) {
styles.addAll(layerInfo.getStyles());
} }
final Set<StyleInfo> otherStyles = layerInfo.getStyles();
if (otherStyles != null && !otherStyles.isEmpty()) { for (StyleInfo si : styles) {
for (StyleInfo si : otherStyles) { File styleFile = findStyle(si);
styleFile = findStyle(si); if (styleFile != null) {
if (styleFile != null) { styleFiles.add(styleFile);
styles.add(styleFile);
}
} }
} }
return styles; return styleFiles;
} }
} }
Expand Up @@ -19,6 +19,7 @@
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.geoserver.catalog.FeatureTypeInfo; import org.geoserver.catalog.FeatureTypeInfo;
import org.geoserver.catalog.LayerInfo;
import org.geoserver.data.test.MockData; import org.geoserver.data.test.MockData;
import org.geoserver.data.test.SystemTestData; import org.geoserver.data.test.SystemTestData;
import org.geoserver.data.util.IOUtils; import org.geoserver.data.util.IOUtils;
Expand Down Expand Up @@ -48,6 +49,7 @@
import org.geotools.util.NullProgressListener; import org.geotools.util.NullProgressListener;
import org.geotools.util.logging.Logging; import org.geotools.util.logging.Logging;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeature;
import org.opengis.util.InternationalString; import org.opengis.util.InternationalString;
Expand Down Expand Up @@ -141,6 +143,11 @@ protected void setUpTestData(SystemTestData testData) throws Exception {
"download-process/download.properties"), "download.properties"); "download-process/download.properties"), "download.properties");
} }


@Before
public void clearPolygons() throws IOException {
revertLayer(MockData.POLYGONS);
}

/** /**
* Test get features as shapefile. * Test get features as shapefile.
* *
Expand Down Expand Up @@ -181,6 +188,22 @@ public void testGetFeaturesAsShapefile() throws Exception {
Assert.assertEquals(rawSource.size(), rawTarget.size()); Assert.assertEquals(rawSource.size(), rawTarget.size());
} }


/**
* Test downloading with a duplicate style
*
* @throws Exception the exception
*/
@Test
public void testDownloadWithDuplicateStyle() throws Exception {
String polygonsName = getLayerId(MockData.POLYGONS);
LayerInfo li = getCatalog().getLayerByName(polygonsName);
// setup an alternative equal to the main style
li.getStyles().add(li.getDefaultStyle());
getCatalog().save(li);

testGetFeaturesAsShapefile();
}

/** /**
* Test filtered clipped features. * Test filtered clipped features.
* *
Expand Down

0 comments on commit 134c72f

Please sign in to comment.