Skip to content

Commit

Permalink
Collections CRUD basic methods
Browse files Browse the repository at this point in the history
  • Loading branch information
aaime committed Jun 28, 2017
1 parent cd3f49d commit 84480ff
Show file tree
Hide file tree
Showing 18 changed files with 1,332 additions and 212 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public String getPrefix() {

}

/**
* Local part of the HTML description property. The namespace is the one assigned to the store, this is not an EO property
*/
public static String DESCRIPTION = "htmlDescription";

/**
* Returns the feature source backing collections (dynamic, as the store has to respect the namespace URI given by GeoServer)
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ paths:
examples:
application/json: |
{
links: [
"links": [
{
"offering": "http://www.opengis.net/spec/owc/1.0/req/atom/wms",
"method": "GET",
Expand Down
4 changes: 4 additions & 0 deletions src/community/oseo/oseo-rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
<artifactId>gt-geojson</artifactId>
<version>${gt.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
package org.geoserver.opensearch.rest;

import java.io.IOException;
import java.io.StringReader;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.geoserver.opensearch.eo.OpenSearchAccessProvider;
import org.geoserver.opensearch.eo.response.LinkFeatureComparator;
import org.geoserver.opensearch.eo.store.OpenSearchAccess;
Expand Down Expand Up @@ -40,6 +45,9 @@
import org.opengis.feature.type.PropertyDescriptor;
import org.opengis.filter.FilterFactory2;
import org.springframework.http.HttpStatus;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

/**
* Base class for OpenSearch related REST controllers
Expand Down Expand Up @@ -155,7 +163,7 @@ protected SimpleFeatureType mapFeatureTypeToSimple(FeatureType schema,
return targetSchema;
}

protected OgcLinks buildOgcLinksFromFeature(Feature feature) {
protected OgcLinks buildOgcLinksFromFeature(Feature feature, boolean notFoundOnEmpty) {
// map to a list of beans
List<OgcLink> links = Collections.emptyList();
Collection<Property> linkProperties = feature
Expand All @@ -171,6 +179,9 @@ protected OgcLinks buildOgcLinksFromFeature(Feature feature) {
return new OgcLink(offering, method, code, type, href);
}).collect(Collectors.toList());
}
if(links.isEmpty() && notFoundOnEmpty) {
throw new ResourceNotFoundException();
}
return new OgcLinks(links);
}

Expand Down Expand Up @@ -238,5 +249,24 @@ public void close() {
}
};
}

/**
* Checks XML well formedness (TODO: check against actual schemas)
*
* @param xml
* @throws IOException
* @throws SAXException
*/
protected void checkWellFormedXML(String xml) {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder;
try {
dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(new InputSource(new StringReader(xml)));
} catch (ParserConfigurationException | SAXException | IOException e) {
throw new RestException("XML document is not well formed", HttpStatus.BAD_REQUEST);
}

}

}

0 comments on commit 84480ff

Please sign in to comment.