Skip to content

Commit

Permalink
Fixed issue where CSWRecords with null OnlineResources would cause th…
Browse files Browse the repository at this point in the history
…e KnownLayers build to fail silently.
  • Loading branch information
stuartwoodman committed Sep 19, 2024
1 parent 71db293 commit 2063f9d
Showing 1 changed file with 41 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@ public String getServiceName() {
* @return the online resources
*/
public List<AbstractCSWOnlineResource> getOnlineResources() {
return onlineResources;
if (onlineResources == null) {
onlineResources = new ArrayList<AbstractCSWOnlineResource>();
}
return onlineResources;
}

/**
Expand Down Expand Up @@ -706,23 +709,24 @@ public String toString() {
*/
public List<AbstractCSWOnlineResource> getOnlineResourcesByType(AbstractCSWOnlineResource.OnlineResourceType... types) {
List<AbstractCSWOnlineResource> result = new ArrayList<>();

for (AbstractCSWOnlineResource r : onlineResources) {
if (r == null) {
continue;
}
boolean matching = false;
AbstractCSWOnlineResource.OnlineResourceType typeToMatch = r.getType();
for (AbstractCSWOnlineResource.OnlineResourceType type : types) {
if (typeToMatch == type) {
matching = true;
break;
}
}

if (matching) {
result.add(r);
}
if (onlineResources != null) {
for (AbstractCSWOnlineResource r : onlineResources) {
if (r == null) {
continue;
}
boolean matching = false;
AbstractCSWOnlineResource.OnlineResourceType typeToMatch = r.getType();
for (AbstractCSWOnlineResource.OnlineResourceType type : types) {
if (typeToMatch == type) {
matching = true;
break;
}
}

if (matching) {
result.add(r);
}
}
}

return result;
Expand All @@ -743,24 +747,25 @@ public List<AbstractCSWOnlineResource> getOnlineResourcesByType(
CSWRecordsFilterVisitor visitor,
AbstractCSWOnlineResource.OnlineResourceType... types) {
List<AbstractCSWOnlineResource> result = new ArrayList<>();

for (AbstractCSWOnlineResource r : onlineResources) {
if (r == null) {
continue;
}
boolean matching = false;
AbstractCSWOnlineResource.OnlineResourceType typeToMatch = r
.getType();
for (AbstractCSWOnlineResource.OnlineResourceType type : types) {
if (typeToMatch == type) {
matching = true;
break;
}
}

if (matching && r.accept(visitor)) {
result.add(r);
}
if (onlineResources != null) {
for (AbstractCSWOnlineResource r : onlineResources) {
if (r == null) {
continue;
}
boolean matching = false;
AbstractCSWOnlineResource.OnlineResourceType typeToMatch = r
.getType();
for (AbstractCSWOnlineResource.OnlineResourceType type : types) {
if (typeToMatch == type) {
matching = true;
break;
}
}

if (matching && r.accept(visitor)) {
result.add(r);
}
}
}

return result;
Expand Down

0 comments on commit 2063f9d

Please sign in to comment.