Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/wcs-client #89

Merged
merged 24 commits into from
Oct 16, 2017
Merged

Feature/wcs-client #89

merged 24 commits into from
Oct 16, 2017

Conversation

jampukka
Copy link
Member

Groundwork for WCS client library module
Support for creating WCS GetCapabilities, DescribeCoverage, GetCoverage requests
Support for parsing WCS GetCapabilities and DescribeCoverage responses

* Check if the coverage appears in the GetCapabilities response
*/
public boolean servesCoverage(String coverageId) {
if (coverageId == null || coverageId.length() == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String.isEmpty() is used in other places of Oskari. No biggie - just a heads up.

* Check if the format appears in the GetCapabilities response
*/
public boolean supportsFormat(String format) {
if (format == null || format.length() == 0) {
Copy link
Member

@ZakarFin ZakarFin Oct 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here with length() == 0 -> isEmpty(). I'll stop mentioning for the rest of these :)

return new Envelope(srsName, srsDimension, axisLabels, uomLabels, lowerCorner, upperCorner);
}

public static Optional<double[]> parseDoubleArray(String str, char c) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These parse methods (parseDoubleArray, parseIntArray, parseInt) are very similar to what ConversionHelper already has, but using Optionals. I would suggest that these should be in ConversionHelper, but that would mean a load of dependencies that you don't otherwise need.

Should we add a new utility-module that has no dependencies and could hold classes with these kinds of functions?

return CommonParser.parsePoint(pointE, dimension);
}

private static String[] parseAxisLables(Element gridEnvelopeE, int dimension) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here parseAxisLables() -> parseAxisLabels()

* @param get true if you want the GET endpoint, false if POST
* @return the endpoint which might not exist for your binding
*/
public static Optional<String> getDescribeCoverageEndPoint(Capabilities wcs, boolean get) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure how I feel about the name "get". How would you feel about "useGet" or having two methods: one for get and another for post?


public class CapabilitiesParser {

public static final String ALLOWED_VERSION = "2.0.1";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be used in all the code for WCS here having the "2.0.1" version as string to make it easier to find where version references are?

return Maps.of(
"service", "WCS",
"version", "2.0.1",
"request", "DescribeCoverage",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should DescribeCoverage, GetCapabilities etc be declared as an enum and used here (and other similar places)?

return join(values, ',');
}

private static String join(String[] a, char c) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well be a public util-method in another class?


public static Document readDocument(InputStream in) throws ParserConfigurationException,
SAXException, IOException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider configuring dbf with some XEE prevention:

   dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);

https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Prevention_Cheat_Sheet

import org.w3c.dom.Node;
import org.xml.sax.SAXException;

public class XML {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class feels like it should be in that no-dependencies util-module that I mentioned in a comment above.

@ZakarFin
Copy link
Member

ZakarFin commented Oct 5, 2017

Nice work! Check the comments, but looks like this is good for merging.

@ZakarFin ZakarFin added this to the 1.45.0 milestone Oct 16, 2017
@ZakarFin ZakarFin merged commit 534a1e8 into oskariorg:develop Oct 16, 2017
@jampukka jampukka deleted the feature/wcs-client branch October 17, 2017 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants