diff --git a/src/plugin/web/src/main/java/org/geoserver/acl/plugin/web/accessrules/model/MutableAccessRequest.java b/src/plugin/web/src/main/java/org/geoserver/acl/plugin/web/accessrules/model/MutableAccessRequest.java index 4a57359..e8292f3 100644 --- a/src/plugin/web/src/main/java/org/geoserver/acl/plugin/web/accessrules/model/MutableAccessRequest.java +++ b/src/plugin/web/src/main/java/org/geoserver/acl/plugin/web/accessrules/model/MutableAccessRequest.java @@ -17,7 +17,7 @@ public class MutableAccessRequest implements Serializable { private String user; - private Set roles = new HashSet<>(); + private final Set roles = new HashSet<>(); private String sourceAddress; private String service; @@ -27,6 +27,11 @@ public class MutableAccessRequest implements Serializable { private String workspace; private String layer; + public void setRoles(Set roles) { + this.roles.clear(); + if (roles != null) this.roles.addAll(roles); + } + public AccessRequest toRequest() { return AccessRequest.builder() .layer(layer) diff --git a/src/plugin/web/src/main/java/org/geoserver/acl/plugin/web/accessrules/model/MutableLayerDetails.java b/src/plugin/web/src/main/java/org/geoserver/acl/plugin/web/accessrules/model/MutableLayerDetails.java index 83bbedc..5be2947 100644 --- a/src/plugin/web/src/main/java/org/geoserver/acl/plugin/web/accessrules/model/MutableLayerDetails.java +++ b/src/plugin/web/src/main/java/org/geoserver/acl/plugin/web/accessrules/model/MutableLayerDetails.java @@ -37,8 +37,8 @@ public class MutableLayerDetails implements Serializable { private MultiPolygon area; private SpatialFilterType spatialFilterType; private CatalogMode catalogMode; - private Set allowedStyles = new TreeSet<>(); - private List attributes = new ArrayList<>(); + private final Set allowedStyles = new TreeSet<>(); + private final List attributes = new ArrayList<>(); public MutableLayerDetails() {} @@ -50,17 +50,25 @@ public MutableLayerDetails(@NonNull LayerDetails ld) { setArea(ld.getArea()); setCatalogMode(ld.getCatalogMode()); setSpatialFilterType(ld.getSpatialFilterType()); - setAllowedStyles(new TreeSet<>(ld.getAllowedStyles())); + setAllowedStyles(ld.getAllowedStyles()); setAttributes(ld.getAttributes().stream().map(MutableLayerAttribute::new).toList()); } + public void setAllowedStyles(Set styles) { + this.allowedStyles.clear(); + if (null != styles) this.allowedStyles.addAll(styles); + } + + public void setAttributes(List list) { + this.attributes.clear(); + if (null != list) this.attributes.addAll(list); + } + public LayerDetails toLayerDetails() { Set atts = - attributes == null || attributes.isEmpty() - ? Set.of() - : attributes.stream() - .map(MutableLayerAttribute::toLayerAttribute) - .collect(Collectors.toSet()); + attributes.stream() + .map(MutableLayerAttribute::toLayerAttribute) + .collect(Collectors.toSet()); Builder builder = LayerDetails.builder() .type(layerType)