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

#222 Improve filtering by role #223

Merged
merged 4 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/gui/core/plugin/mapsui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence-gui-plugin</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.5.1</version>
</parent>

<groupId>org.geoserver.geofence</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/gui/core/plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence-gui-core</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.5.1</version>
</parent>

<groupId>org.geoserver.geofence</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/gui/core/plugin/userui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence-gui-plugin</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.5.1</version>
</parent>

<groupId>org.geoserver.geofence</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/gui/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence-gui-root</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.5.1</version>
</parent>

<groupId>org.geoserver.geofence</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/gui/core/resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence-gui-core</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.5.1</version>
</parent>

<groupId>org.geoserver.geofence</groupId>
Expand Down
12 changes: 6 additions & 6 deletions src/gui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
<parent>
<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.5.1</version>
</parent>

<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence-gui-root</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.5.1</version>
<packaging>pom</packaging>

<name>GeoFence - GUI</name>

<properties>
<module.name>geofence-gui</module.name>
<geofence-version>3.5-SNAPSHOT</geofence-version>
<geofence-version>3.5.1</geofence-version>
<gt-version>21.4</gt-version>
<geogwt-version>0.4-SNAPSHOT</geogwt-version>

Expand Down Expand Up @@ -59,16 +59,16 @@
<repository>
<id>geosolutions</id>
<name>GeoSolutions Repository</name>
<url>http://maven.geo-solutions.it</url>
<url>https://maven.geo-solutions.it</url>
</repository>
<repository>
<id>gwt-maven</id>
<url>http://gwt-maven.googlecode.com/svn/trunk/mavenrepo</url>
<url>https://gwt-maven.googlecode.com/svn/trunk/mavenrepo</url>
</repository>
<repository>
<id>maven-restlet</id>
<name>Restlet Maven Repository</name>
<url>http://maven.restlet.org</url>
<url>https://maven.restlet.org</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
Expand Down
2 changes: 1 addition & 1 deletion src/gui/web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence-gui-root</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.5.1</version>
</parent>

<groupId>org.geoserver.geofence</groupId>
Expand Down
7 changes: 3 additions & 4 deletions src/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.5.1</version>
<packaging>pom</packaging>

<properties>
<geofence-version>3.5-SNAPSHOT</geofence-version>
<geofence-version>3.5.1</geofence-version>
<hibernate-version>3.6.9.Final</hibernate-version>
<hibernate-generic-dao-version>1.1.0</hibernate-generic-dao-version>
<hibernate-spatial-version>1.1.3.2</hibernate-spatial-version>
Expand Down Expand Up @@ -50,7 +50,6 @@
<name>Alessio Fabiani</name>
<organization>GeoSolutions</organization>
<roles>
<role>architect</role>
<role>developer</role>
</roles>
<timezone>+2</timezone>
Expand Down Expand Up @@ -101,7 +100,7 @@
<repository>
<id>geosolutions</id>
<name>GeoSolutions Repository</name>
<url>http://maven.geo-solutions.it/</url>
<url>https://maven.geo-solutions.it/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
Expand Down
2 changes: 1 addition & 1 deletion src/samples/csv2geofence/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>org.geoserver.geofence.sample</groupId>
<artifactId>csv2geofence</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.5.1</version>
<packaging>jar</packaging>

<name>csv2geofence</name>
Expand Down
2 changes: 1 addition & 1 deletion src/services/core/model-external/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence-core</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.5.1</version>
</parent>

<groupId>org.geoserver.geofence</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/services/core/model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence-core</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.5.1</version>
</parent>

<groupId>org.geoserver.geofence</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/services/core/persistence-pg-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence-core</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.5.1</version>
</parent>

<groupId>org.geoserver.geofence</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/services/core/persistence/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence-core</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.5.1</version>
</parent>

<groupId>org.geoserver.geofence</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/services/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence-root</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.5.1</version>
</parent>

<groupId>org.geoserver.geofence</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/services/core/services-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence-core</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.5.1</version>
</parent>

<groupId>org.geoserver.geofence</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
import org.geoserver.geofence.core.model.Rule;

import java.io.Serializable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;


/**
Expand All @@ -25,7 +29,7 @@
*/
public class RuleFilter implements Serializable, Cloneable {

private static final long serialVersionUID = 5629211135629700042L;
private static final long serialVersionUID = 5629211135629700043L;

public enum FilterType {

Expand Down Expand Up @@ -159,6 +163,7 @@ public RuleFilter setUser(SpecialFilterType type) {
public RuleFilter setRole(String name) {
if(name == null)
throw new NullPointerException();
name = sortNames(name); // force ordering to preserve hashing
role.setText(name);
return this;
}
Expand Down Expand Up @@ -276,6 +281,17 @@ public TextFilter getWorkspace() {
// return this;
// }


private String sortNames(String s) {
if(s.contains(",")) {
s = Arrays.asList(s.split(",")).stream()
.map(n -> n.trim())
.sorted()
.collect(Collectors.joining(","));
}
return s;
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.geoserver.geofence.services.util;

import org.geoserver.geofence.services.dto.RuleFilter;
import static org.junit.Assert.*;
import org.junit.Test;

/**
*
*/
public class RuleFilterTest {
@Test
public void testRole() {
RuleFilter f = new RuleFilter();
f.setRole("pippo");
assertEquals("pippo", f.getRole().getText());

f.setRole("a,b");
assertEquals("a,b", f.getRole().getText());

f.setRole("b,a");
assertEquals("a,b", f.getRole().getText());

f.setRole("a, b");
assertEquals("a,b", f.getRole().getText());

f.setRole(" b , a ");
assertEquals("a,b", f.getRole().getText());
}

}
2 changes: 1 addition & 1 deletion src/services/core/services-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence-core</artifactId>
<version>3.5-SNAPSHOT</version>
<version>3.5.1</version>
</parent>

<groupId>org.geoserver.geofence</groupId>
Expand Down
Loading