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/update-capabilities-automatically #86

Merged
merged 59 commits into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
3780ef7
Add UpdateLayerCapabilities ActionHandler for WMS and WMTS layers
jampukka Aug 1, 2017
45a78b4
Tiny refactoring
jampukka Aug 1, 2017
338220d
Delete as unused
jampukka Aug 1, 2017
47e9924
Add few logging statements
jampukka Aug 1, 2017
3257290
Merge branch 'develop' into feature/timeseries-capabilities
jampukka Aug 10, 2017
39d10f1
Temp commit
jampukka Aug 10, 2017
88093a3
Merge remote-tracking branch 'oskari/develop' into feature/timeseries…
jampukka Aug 14, 2017
a8be392
Delete InMemoryImpl
jampukka Aug 15, 2017
210f6bb
Change OskariLayerCapabilities to immutable, make necessary changes t…
jampukka Aug 16, 2017
8c7e2cf
Change type of OskariLayerCapabilities.created and updated from java.…
jampukka Aug 16, 2017
02a797d
Create a separate class OskariLayerCapabilitiesDraft for non-persiste…
jampukka Aug 16, 2017
5da1c3b
Rename CapabilitiesInsertInfo to OskariLayerCapabilitiesInsertInfo
jampukka Aug 16, 2017
a6eec6a
Update CapabilitiesCacheServiceMock to reflect changes in OskariLayer…
jampukka Aug 16, 2017
e884427
Fix issue with executing updates or inserts within @Select() annotati…
jampukka Aug 17, 2017
a5c2a01
Add ServiceExceptions to CapabilitiesCacheService
jampukka Aug 17, 2017
889b3cc
Remove OskariLayerCapabilitiesDraft, change OskariLayerCapabilities t…
jampukka Aug 21, 2017
4f450b6
Change OskariLayerCapabilities to mostly immutable
jampukka Aug 21, 2017
8fc0f6b
Fix Mock class
jampukka Aug 21, 2017
a3cc9be
Move logic that handles GetCapabilities information from SaveLayerHan…
jampukka Aug 23, 2017
b35b35e
Remove UpdateLayerCapabilitiesHandler not necessary with scheduled im…
jampukka Aug 23, 2017
a2a11c0
Remove unuseful test
jampukka Aug 23, 2017
5db326d
Add few utility methods
jampukka Aug 25, 2017
0ea589b
Add logic that checks that the response from service is a proper GetC…
jampukka Aug 25, 2017
860feba
Remove extra whitespace before linebreak
jampukka Aug 25, 2017
4389009
Tiny fixes
jampukka Sep 5, 2017
7f4c3e8
Fix imports
jampukka Sep 13, 2017
3da69c4
Fix imports part2
jampukka Sep 13, 2017
1ed5ad7
Use PARAM_SRS_NAME instead of "srs_name"
jampukka Sep 13, 2017
f8f8e31
validateCapabilities() now throws ServiceExceptions instead of return…
jampukka Sep 13, 2017
6439ff5
Remove as unused
jampukka Sep 13, 2017
457cb75
Merge oskari/develop
jampukka Sep 14, 2017
1f556de
Add newline to end of file, dont add new lines where not necessary
jampukka Sep 14, 2017
858ab19
Refactor WMTSCapabilitiesParser
jampukka Sep 14, 2017
2980b2d
Remove Collection.unmodifiableXXX() wrappers
jampukka Sep 15, 2017
8789012
Little clean ups
jampukka Sep 15, 2017
4067133
Log invalid TileMatrixLimits instead of throwing an exception, add as…
jampukka Sep 15, 2017
1dd9c04
Improve error handling
jampukka Sep 15, 2017
131cea5
Add support for setting the maxAge via property
jampukka Sep 15, 2017
c1dad75
Add a test, not really a unit testable class
jampukka Sep 15, 2017
c2c0546
Add this back, maybe its needed, who knows
jampukka Sep 15, 2017
b0a30ca
Fix the Property name
jampukka Sep 15, 2017
2e2a5b5
Prevent crashing while instantiating if DataSource is null
jampukka Sep 18, 2017
222f895
Throw NPE instead of ServiceRuntimeException, more fitting
jampukka Sep 18, 2017
915f6f1
Add backwards compatibility
jampukka Sep 18, 2017
e2e9054
Dont write version column, it doesnt exist yet
jampukka Sep 19, 2017
a783be4
Dont modify xslt parameter
jampukka Sep 19, 2017
a465886
Add service-capabilities-update to parents pom
jampukka Sep 19, 2017
b4a14cd
Add some logging to UpdateCapabilitiesJob
jampukka Sep 19, 2017
78886d6
Fix TileMatrixLimits
jampukka Sep 19, 2017
98c75c1
Dont both log and throw an exception with the same message. Dont retu…
jampukka Oct 2, 2017
a728738
Fix multiple issues, remove support for WMS layers for now
jampukka Oct 3, 2017
5b92460
Undo these unnecessary changes to make the branch more linear
jampukka Oct 3, 2017
dca36d0
Fix text to reflect the removal of wms services
jampukka Oct 3, 2017
1a68242
Move package, change OskariLayerCapabilities full constructor to public
jampukka Oct 3, 2017
90872be
Move package, change OskariLayerCapabilities full constructor to public
jampukka Oct 3, 2017
05ddaff
Merge remote-tracking branch 'oskari/develop' into feature/timeseries…
jampukka Oct 3, 2017
7a344fe
bump version
jampukka Oct 3, 2017
4b2bd87
Merge remote-tracking branch 'oskari/develop' into feature/timeseries…
jampukka Nov 13, 2017
db0cf78
Fix merge
jampukka Nov 13, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove Collection.unmodifiableXXX() wrappers
  • Loading branch information
jampukka committed Sep 15, 2017
commit 2980b2dcbe312f697e9a56e3099dd8df14c45343
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import fi.nls.oskari.wfs.GetGtWFSCapabilities;
import fi.nls.oskari.wms.GetGtWMSCapabilities;
import fi.nls.oskari.wmts.WMTSCapabilitiesParser;
import fi.nls.oskari.wmts.domain.WMTSCapabilities;
import org.json.JSONObject;

/**
Expand Down Expand Up @@ -60,8 +61,6 @@ public void handleAction(ActionParameters params) throws ActionException {
}
else {
if (OskariLayer.TYPE_WMTS.equals(layerType)) {
WMTSCapabilitiesParser parser = new WMTSCapabilitiesParser();

// setup capabilities URL
OskariLayerCapabilities caps = capabilitiesService.getCapabilities(url, OskariLayer.TYPE_WMTS, user, pw, version);
String capabilitiesXML = caps.getData();
Expand All @@ -70,7 +69,8 @@ public void handleAction(ActionParameters params) throws ActionException {
caps = capabilitiesService.getCapabilities(url, OskariLayer.TYPE_WMTS, user, pw, version, true);
capabilitiesXML = caps.getData();
}
JSONObject resultJSON = parser.parseCapabilitiesToJSON(capabilitiesXML, url, currentCrs);
WMTSCapabilities wmtsCaps = WMTSCapabilitiesParser.parseCapabilities(capabilitiesXML);
JSONObject resultJSON = WMTSCapabilitiesParser.asJSON(wmtsCaps, url, currentCrs);
JSONHelper.putValue(resultJSON, "xml", caps.getData());
ResponseHelper.writeResponse(params, resultJSON);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,14 @@
import fi.nls.oskari.domain.map.OskariLayer;
import fi.nls.oskari.map.geometry.ProjectionHelper;
import fi.nls.oskari.util.JSONHelper;
import fi.nls.oskari.wmts.domain.TileMatrixLimits;
import fi.nls.oskari.wmts.domain.TileMatrixSet;
import fi.nls.oskari.wmts.domain.TileMatrixLink;
import fi.nls.oskari.wmts.domain.WMTSCapabilities;
import fi.nls.oskari.wmts.domain.WMTSCapabilitiesLayer;
import org.json.JSONArray;
import org.json.JSONObject;

import java.util.*;

/**
* Created with IntelliJ IDEA.
* User: SMAKINEN
* Date: 17.12.2013
* Time: 15:37
* To change this template use File | Settings | File Templates.
*/
public class LayerJSONFormatterWMTS extends LayerJSONFormatter {

public static final String KEY_TILEMATRIXIDS = "tileMatrixIds";
Expand Down Expand Up @@ -75,69 +68,58 @@ public JSONObject getJSON(OskariLayer layer,
* @return
*/
public static JSONObject createCapabilitiesJSON(final WMTSCapabilities wmts,final WMTSCapabilitiesLayer layer) {

JSONObject capabilities = new JSONObject();
if(layer == null) {
return capabilities;
}

List<JSONObject> tileMatrix = LayerJSONFormatterWMTS.createTileMatrixArray(wmts, layer);
List<JSONObject> tileMatrix = LayerJSONFormatterWMTS.createTileMatrixArray(layer);
JSONHelper.putValue(capabilities, KEY_TILEMATRIXIDS, new JSONArray(tileMatrix));

return capabilities;
}

/**
* Return array of wmts tilematrixsets (Crs code and Identifier)
* @param wmts wmts service capabilities
* @param layer wmts layer capabilities
* @param layer wmts layer capabilities
* @return
*/
public static List<JSONObject> createTileMatrixArray(final WMTSCapabilities wmts, final WMTSCapabilitiesLayer layer) {
public static List<JSONObject> createTileMatrixArray(final WMTSCapabilitiesLayer layer) {
final List<JSONObject> tileMatrix = new ArrayList<>();
Map<String, Set<TileMatrixLimits>> links = layer.getLinks();
if (links.size() > 0 ) {
//Loop matrixSet links
for (Map.Entry<String, Set<TileMatrixLimits>> entry : links.entrySet()) {
String crs = wmts.getMatrixCRS(entry.getKey());
if(crs != null){
tileMatrix.add(JSONHelper.createJSONObject(ProjectionHelper.shortSyntaxEpsg(crs), entry.getKey()));
}
}
if (layer == null) {
return tileMatrix;
}

for (TileMatrixLink link : layer.getLinks()) {
TileMatrixSet tms = link.getTileMatrixSet();
String identifier = tms.getId();
String crs = tms.getCrs();
String epsg = ProjectionHelper.shortSyntaxEpsg(crs);
JSONHelper.createJSONObject(epsg, identifier);
}
return tileMatrix;
}

/**
* Constructs a csr set containing the supported coordinate ref systems of WMS service
*
* @param wmts WebMapService
* @return Set<String> containing the supported coordinate ref systems of WMS service
* Constructs a Set containing the supported Coordinate Reference Systems of WMTS service
*/
public static Set<String> getCRSs(final WMTSCapabilities wmts, final WMTSCapabilitiesLayer layer) {
if(layer == null || wmts == null){
public static Set<String> getCRSs(final WMTSCapabilitiesLayer layer) {
if (layer == null) {
return null;
}

Set<String> crss = new HashSet<String>();

Map<String, Set<TileMatrixLimits>> links = layer.getLinks();
if (links.size() > 0 ) {
//Loop matrixSet links
for (Map.Entry<String, Set<TileMatrixLimits>> entry : links.entrySet()) {
String crs = wmts.getMatrixCRS(entry.getKey());
crss.add(ProjectionHelper.shortSyntaxEpsg(crs));
}
return crss;
Set<String> crss = new HashSet<String>();
for (TileMatrixLink link : layer.getLinks()) {
TileMatrixSet tms = link.getTileMatrixSet();
String crs = tms.getCrs();
String epsg = ProjectionHelper.shortSyntaxEpsg(crs);
crss.add(epsg);
}

return null;
return crss;
}

/**
* Get matrix id by current crs
* @param crs
* @return
*/
public static String getTileMatrixSetId(final JSONObject capabilities, final String crs) {
if (capabilities.has("tileMatrixIds")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static void setPropertiesFromCapabilitiesWMTS(OskariLayerCapabilities cap
crs = crs != null ? crs : ml.getSrs_name();
ml.setTileMatrixSetId(LayerJSONFormatterWMTS.getTileMatrixSetId(jscaps, crs));

ml.setSupportedCRSs(LayerJSONFormatterWMTS.getCRSs(caps, layer));
ml.setSupportedCRSs(LayerJSONFormatterWMTS.getCRSs(layer));
}

public static void setPropertiesFromCapabilitiesWFS(OskariLayer ml) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public class WMTSCapabilitiesParser {
public static WMTSCapabilities parseCapabilities(String xml)
throws IllegalArgumentException, XMLStreamException {
OMElement doc = XmlHelper.parseXML(xml);
return doc != null ? parseCapabilities(doc) : null;
if (doc == null) {
throw new XMLStreamException("Failed to parse XML");
}
return parseCapabilities(doc);
}

public static WMTSCapabilities parseCapabilities(InputStream in)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package fi.nls.oskari.wmts.domain;

import java.util.Collections;
import java.util.List;

public class TileMatrixLink {
Expand All @@ -10,7 +9,7 @@ public class TileMatrixLink {

public TileMatrixLink(TileMatrixSet tms, List<TileMatrixLimits> limits) {
this.tms = tms;
this.limits = limits != null ? Collections.unmodifiableList(limits) : null;
this.limits = limits;
}

public TileMatrixSet getTileMatrixSet() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package fi.nls.oskari.wmts.domain;

import java.util.Collections;
import java.util.stream.Collectors;
import fi.nls.oskari.util.JSONHelper;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.json.JSONArray;
import org.json.JSONObject;

Expand All @@ -23,8 +22,8 @@ public TileMatrixSet(String id, String crs, List<TileMatrix> tileMatrises)
throws IllegalArgumentException {
this.id = id;
this.crs = crs;
this.tileMatrixMap = Collections.unmodifiableMap(tileMatrises.stream()
.collect(Collectors.toMap(TileMatrix::getId, tm -> tm)));
this.tileMatrixMap = tileMatrises.stream()
.collect(Collectors.toMap(TileMatrix::getId, tm -> tm));
validate();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package fi.nls.oskari.wmts.domain;

import java.util.Collection;

import java.util.Collections;
import java.util.Map;

public class WMTSCapabilities {
Expand All @@ -12,8 +10,8 @@ public class WMTSCapabilities {

public WMTSCapabilities(Map<String, TileMatrixSet> tileMatrixSets,
Map<String, WMTSCapabilitiesLayer> layers) {
this.tileMatrixSets = Collections.unmodifiableMap(tileMatrixSets);
this.layers = Collections.unmodifiableMap(layers);
this.tileMatrixSets = tileMatrixSets;
this.layers = layers;
}

public Collection<TileMatrixSet> getTileMatrixSets() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import fi.nls.oskari.map.layer.formatters.LayerJSONFormatterWMS;
import fi.nls.oskari.util.JSONHelper;
import fi.nls.oskari.wms.WMSStyle;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.json.JSONArray;
Expand All @@ -28,32 +27,27 @@ public WMTSCapabilitiesLayer(String id, String title,
List<TileMatrixLink> links) {
this.id = id;
this.title = title;
this.styles = Collections.unmodifiableList(styles);
this.styles = styles;
this.defaultStyle = defaultStyle;
this.formats = Collections.unmodifiableSet(formats);
this.infoFormats = Collections.unmodifiableSet(infoFormats);
this.resourceUrls = Collections.unmodifiableList(resourceUrls);
this.links = Collections.unmodifiableList(links);
this.formats = formats;
this.infoFormats = infoFormats;
this.resourceUrls = resourceUrls;
this.links = links;
}


public List<ResourceUrl> getResourceUrls() {
return resourceUrls;
}

public void addResourceUrl(ResourceUrl url) {
getResourceUrls().add(url);
}
public ResourceUrl getResourceUrlByType(final String type) {
for(ResourceUrl url : resourceUrls) {
if(url.getType().equalsIgnoreCase(type)) {
for (ResourceUrl url : resourceUrls) {
if (url.getType().equalsIgnoreCase(type)) {
return url;
}
}
return null;
}


public boolean isQueryable() {
return infoFormats.size() > 0;
}
Expand Down