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

Reimplement legacy structure xml parsing logic #1098

Merged
merged 1 commit into from
Nov 8, 2022
Merged
Changes from all commits
Commits
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
16 changes: 12 additions & 4 deletions core/src/main/java/tc/oc/pgm/structure/StructureModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import tc.oc.pgm.regions.BlockBoundedValidation;
import tc.oc.pgm.regions.RegionParser;
import tc.oc.pgm.snapshot.SnapshotMatchModule;
import tc.oc.pgm.util.Version;
import tc.oc.pgm.util.xml.InvalidXMLException;
import tc.oc.pgm.util.xml.Node;
import tc.oc.pgm.util.xml.XMLUtils;
Expand Down Expand Up @@ -61,7 +62,8 @@ public static class Factory implements MapModuleFactory<StructureModule> {
@Override
public StructureModule parse(MapFactory factory, Logger logger, Document doc)
throws InvalidXMLException {
if (factory.getProto().isOlderThan(MapProtos.FILTER_FEATURES)) return null;
Version proto = factory.getProto();
if (proto.isOlderThan(MapProtos.FILTER_FEATURES)) return null;

FilterParser filters = factory.getFilters();
RegionParser regions = factory.getRegions();
Expand Down Expand Up @@ -95,9 +97,15 @@ public StructureModule parse(MapFactory factory, Logger logger, Document doc)
final StructureDefinition structure =
structures.get(el.getAttribute("structure").getValue());

Filter trigger =
filters.parseRequiredProperty(el, "trigger", DynamicFilterValidation.MATCH);
Filter filter = filters.parseProperty(el, "filter", StaticFilter.ALLOW);
Filter trigger, filter;
if (proto.isOlderThan(MapProtos.DYNAMIC_FILTERS)) {
// Legacy maps use "filter" as their trigger
trigger = filters.parseRequiredProperty(el, "filter", DynamicFilterValidation.MATCH);
filter = StaticFilter.ALLOW;
} else {
trigger = filters.parseRequiredProperty(el, "trigger", DynamicFilterValidation.MATCH);
filter = filters.parseProperty(el, "filter", StaticFilter.ALLOW);
}

DynamicStructureDefinition definition =
new DynamicStructureDefinition(id, structure, trigger, filter, position, offset);
Expand Down