Various code simplification/fixes and a lot of typo/grammar fixes (may brake some stuff)
This commit is contained in:
@@ -8,7 +8,7 @@ import java.util.Set;
|
||||
import java.util.stream.LongStream;
|
||||
|
||||
import fr.pandacube.lib.chat.ChatTreeNode;
|
||||
import fr.pandacube.lib.permissions.PermissionExpressionParser.LitteralPermissionTester;
|
||||
import fr.pandacube.lib.permissions.PermissionExpressionParser.LiteralPermissionTester;
|
||||
import fr.pandacube.lib.permissions.PermissionsCachedBackendReader.CachedEntity;
|
||||
import fr.pandacube.lib.permissions.SQLPermissions.EntityType;
|
||||
import fr.pandacube.lib.util.Log;
|
||||
@@ -87,8 +87,8 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides informations on how the effective prefix of this entity is determined.
|
||||
* @return a {@link ChatTreeNode} providing informations on how the effective prefix of this entity is determined.
|
||||
* Provides information on how the effective prefix of this entity is determined.
|
||||
* @return a {@link ChatTreeNode} providing information on how the effective prefix of this entity is determined.
|
||||
*/
|
||||
public ChatTreeNode debugPrefix() {
|
||||
return Permissions.resolver.debugPrefix(name, type);
|
||||
@@ -124,8 +124,8 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides informations on how the effective suffix of this entity is determined.
|
||||
* @return a {@link ChatTreeNode} providing informations on how the effective suffix of this entity is determined.
|
||||
* Provides information on how the effective suffix of this entity is determined.
|
||||
* @return a {@link ChatTreeNode} providing information on how the effective suffix of this entity is determined.
|
||||
*/
|
||||
public ChatTreeNode debugSuffix() {
|
||||
return Permissions.resolver.debugSuffix(name, type);
|
||||
@@ -147,7 +147,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup {
|
||||
/**
|
||||
* Gets the effective list of permissions that applies to this entity out of a specific server and world.
|
||||
* It is either the permissions defined directly for this entity, or from inheritance as long as they are not
|
||||
* overriden.
|
||||
* overridden.
|
||||
* @return the effective list of permissions that applies to this entity out of a specific server and world.
|
||||
*/
|
||||
public Map<String, Boolean> listEffectivePermissions() {
|
||||
@@ -157,7 +157,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup {
|
||||
/**
|
||||
* Gets the effective list of permissions that applies to this entity on a specific server.
|
||||
* It is either the permissions defined directly for this entity, or from inheritance as long as they are not
|
||||
* overriden.
|
||||
* overridden.
|
||||
* @param server the server where the returned permissions apply for this entity.
|
||||
* @return the effective list of permissions that applies to this entity on a specific server.
|
||||
*/
|
||||
@@ -168,7 +168,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup {
|
||||
/**
|
||||
* Gets the effective list of permissions that applies to this entity on a specific server and world.
|
||||
* It is either the permissions defined directly for this entity, or from inheritance as long as they are not
|
||||
* overriden.
|
||||
* overridden.
|
||||
* @param server the server containing the world where the returned permissions apply for this entity.
|
||||
* @param world the world in the server where the returned permissions apply for this entity.
|
||||
* @return the effective list of permissions that applies to this entity on a specific server and world.
|
||||
@@ -187,7 +187,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup {
|
||||
* Gets the effective values of the provided permission range prefix that applies to this entity out of a specific
|
||||
* server and world.
|
||||
* It is either the range values defined directly for this entity, or from inheritance as long as they are not
|
||||
* overriden.
|
||||
* overridden.
|
||||
* @param permissionPrefix the permission range prefix.
|
||||
* @return the effective values of the provided permission range prefix that applies to this entity out of a
|
||||
* specific server and world.
|
||||
@@ -200,7 +200,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup {
|
||||
* Gets the effective values of the provided permission range prefix that applies to this entity on a specific
|
||||
* server.
|
||||
* It is either the range values defined directly for this entity, or from inheritance as long as they are not
|
||||
* overriden.
|
||||
* overridden.
|
||||
* @param permissionPrefix the permission range prefix.
|
||||
* @param server the server where the returned values apply for this entity.
|
||||
* @return the effective values of the provided permission range prefix that applies to this entity on a specific
|
||||
@@ -214,7 +214,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup {
|
||||
* Gets the effective values of the provided permission range prefix that applies to this entity on a specific
|
||||
* server and world.
|
||||
* It is either the range values defined directly for this entity, or from inheritance as long as they are not
|
||||
* overriden.
|
||||
* overridden.
|
||||
* @param permissionPrefix the permission range prefix.
|
||||
* @param server the server containing the world where the returned values apply for this entity.
|
||||
* @param world the world in the server where the returned values apply for this entity.
|
||||
@@ -247,7 +247,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup {
|
||||
* Gets the maximum effective value of the provided permission range prefix that applies to this entity out of a
|
||||
* specific server and world.
|
||||
* It is either the range values defined directly for this entity, or from inheritance as long as they are not
|
||||
* overriden.
|
||||
* overridden.
|
||||
* @param permissionPrefix the permission range prefix.
|
||||
* @return the maximum effective value of the provided permission range prefix that applies to this entity out of a
|
||||
* specific server and world.
|
||||
@@ -260,7 +260,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup {
|
||||
* Gets the maximum effective value of the provided permission range prefix that applies to this entity on a
|
||||
* specific server.
|
||||
* It is either the range values defined directly for this entity, or from inheritance as long as they are not
|
||||
* overriden.
|
||||
* overridden.
|
||||
* @param permissionPrefix the permission range prefix.
|
||||
* @param server the server where the returned value applies for this entity.
|
||||
* @return the maximum effective value of the provided permission range prefix that applies to this entity on a
|
||||
@@ -274,7 +274,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup {
|
||||
* Gets the maximum effective value of the provided permission range prefix that applies to this entity on a
|
||||
* specific server and world.
|
||||
* It is either the range values defined directly for this entity, or from inheritance as long as they are not
|
||||
* overriden.
|
||||
* overridden.
|
||||
* @param permissionPrefix the permission range prefix.
|
||||
* @param server the server containing the world where the returned value applies for this entity.
|
||||
* @param world the world in the server where the returned value applies for this entity.
|
||||
@@ -294,8 +294,8 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup {
|
||||
/**
|
||||
* Tells if this entity has the provided permission out of a specific server and world.
|
||||
* It is either based on the permissions defined directly for this entity, or from inheritance as long as they are
|
||||
* not overriden.
|
||||
* @param permission the permission to ckeck on this entity.
|
||||
* not overridden.
|
||||
* @param permission the permission to check on this entity.
|
||||
* @return true if this entity has the permission, false if it is negated, or null if not known.
|
||||
*/
|
||||
public Boolean hasPermission(String permission) {
|
||||
@@ -303,10 +303,10 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if this entity has the provided permission on a specitif server.
|
||||
* Tells if this entity has the provided permission on a specific server.
|
||||
* It is either based on the permissions defined directly for this entity, or from inheritance as long as they are
|
||||
* not overriden. It also consider permissions that apply on any server.
|
||||
* @param permission the permission to ckeck on this entity.
|
||||
* not overridden. It also considers permissions that apply on any server.
|
||||
* @param permission the permission to check on this entity.
|
||||
* @param server the server in which to test the permission for this entity.
|
||||
* @return true if this entity has the permission, false if it is negated, or null if not known.
|
||||
*/
|
||||
@@ -315,10 +315,10 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if this entity has the provided permission on a specitif server and world.
|
||||
* Tells if this entity has the provided permission on a specific server and world.
|
||||
* It is either based on the permissions defined directly for this entity, or from inheritance as long as they are
|
||||
* not overriden. It also consider permissions that apply on any world of that server, and then any server.
|
||||
* @param permission the permission to ckeck on this entity.
|
||||
* not overridden. It also considers permissions that apply on any world of that server, and then any server.
|
||||
* @param permission the permission to check on this entity.
|
||||
* @param server the server in which to test the permission for this entity.
|
||||
* @param world the world in which to test the permission for this entity.
|
||||
* @return true if this entity has the permission, false if it is negated, or null if not known.
|
||||
@@ -330,10 +330,10 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if this entity has the provided permission on a specitif server and world.
|
||||
* Tells if this entity has the provided permission on a specific server and world.
|
||||
* It is either based on the permissions defined directly for this entity, or from inheritance as long as they are
|
||||
* not overriden.
|
||||
* @param permission the permission to ckeck on this entity.
|
||||
* not overridden.
|
||||
* @param permission the permission to check on this entity.
|
||||
* @param server the server in which to test the permission for this entity.
|
||||
* @param world the world in which to test the permission for this entity.
|
||||
* @param deflt the default value is the permission is undefined for this entity.
|
||||
@@ -347,12 +347,12 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup {
|
||||
/**
|
||||
* Evaluates the provided permission expression for this entity.
|
||||
* It uses {@link #hasPermissionOr(String, String, String, boolean)} with {@code false} as a default value, to check
|
||||
* each permission nodes individualy.
|
||||
* each permission nodes individually.
|
||||
* @param permExpression the permission expression to evaluate on this entity.
|
||||
* @param server the server in which to test the permission expression for this entity.
|
||||
* @param world the world in which to test the permission expression for this entity.
|
||||
* @return true if this the permission expression evaluates to true, false otherwise.
|
||||
* @see PermissionExpressionParser#evaluate(String, LitteralPermissionTester)
|
||||
* @see PermissionExpressionParser#evaluate(String, LiteralPermissionTester)
|
||||
*/
|
||||
public boolean hasPermissionExpression(String permExpression, String server, String world) {
|
||||
return PermissionExpressionParser.evaluate(permExpression, p -> hasPermissionOr(p, server, world, false));
|
||||
@@ -367,33 +367,33 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup {
|
||||
|
||||
|
||||
/**
|
||||
* Provides informations on how the effective permission of this entity on the provided permission node is
|
||||
* Provides information on how the effective permission of this entity on the provided permission node is
|
||||
* determined.
|
||||
* @param permission the permission node to debug on this entity.
|
||||
* @return a {@link ChatTreeNode} providing informations on how the effective permission is determined.
|
||||
* @return a {@link ChatTreeNode} providing information on how the effective permission is determined.
|
||||
*/
|
||||
public ChatTreeNode debugPermission(String permission) {
|
||||
return debugPermission(permission, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides informations on how the effective permission of this entity on the provided permission node is
|
||||
* Provides information on how the effective permission of this entity on the provided permission node is
|
||||
* determined.
|
||||
* @param permission the permission node to debug on this entity.
|
||||
* @param server the server in which to test the permission for this entity.
|
||||
* @return a {@link ChatTreeNode} providing informations on how the effective permission is determined.
|
||||
* @return a {@link ChatTreeNode} providing information on how the effective permission is determined.
|
||||
*/
|
||||
public ChatTreeNode debugPermission(String permission, String server) {
|
||||
return debugPermission(permission, server, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides informations on how the effective permission of this entity on the provided permission node is
|
||||
* Provides information on how the effective permission of this entity on the provided permission node is
|
||||
* determined.
|
||||
* @param permission the permission node to debug on this entity.
|
||||
* @param server the server in which to test the permission for this entity.
|
||||
* @param world the world in which to test the permission for this entity.
|
||||
* @return a {@link ChatTreeNode} providing informations on how the effective permission is determined.
|
||||
* @return a {@link ChatTreeNode} providing information on how the effective permission is determined.
|
||||
*/
|
||||
public ChatTreeNode debugPermission(String permission, String server, String world) {
|
||||
return Permissions.resolver.debugPermission(name, type, permission, server, world);
|
||||
|
@@ -11,7 +11,7 @@ import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Represents an group in the permission system.
|
||||
* Represents a group in the permission system.
|
||||
*/
|
||||
public final class PermGroup extends PermEntity {
|
||||
/* package */ PermGroup(String name) {
|
||||
@@ -54,7 +54,7 @@ public final class PermGroup extends PermEntity {
|
||||
* Gets all the players that inherits from this group.
|
||||
* This method does not use cached data.
|
||||
* @param recursive true to include players that are in inherited groups.
|
||||
* @return the players that inherits from this group.
|
||||
* @return the players that inherit from this group.
|
||||
* @throws DBException if a database error occurs.
|
||||
*/
|
||||
public Set<UUID> getInheritedPlayers(boolean recursive) throws DBException {
|
||||
@@ -69,7 +69,7 @@ public final class PermGroup extends PermEntity {
|
||||
|
||||
/**
|
||||
* Tells if this group is a default group.
|
||||
* A player inherits all default groups when they don’t explicitely inherit from at least one group.
|
||||
* A player inherits all default groups when they don’t explicitly inherit from at least one group.
|
||||
* @return true if this group is a default group, false otherwise.
|
||||
*/
|
||||
public boolean isDefault() {
|
||||
@@ -78,7 +78,7 @@ public final class PermGroup extends PermEntity {
|
||||
|
||||
/**
|
||||
* Sets this group as a default group or not.
|
||||
* All players that don’t explicitely inherit from at least one group will either start or stop implicitely
|
||||
* All players that don’t explicitly inherit from at least one group will either start or stop implicitly
|
||||
* inheriting from this group.
|
||||
* @param deflt true to set this group as default, false to set is as not default.
|
||||
*/
|
||||
|
@@ -8,7 +8,7 @@ import fr.pandacube.lib.permissions.PermissionsCachedBackendReader.CachedPlayer;
|
||||
import fr.pandacube.lib.permissions.SQLPermissions.EntityType;
|
||||
|
||||
/**
|
||||
* Represents an player in the permission system.
|
||||
* Represents a player in the permission system.
|
||||
*/
|
||||
public final class PermPlayer extends PermEntity {
|
||||
private final UUID playerId;
|
||||
@@ -84,7 +84,7 @@ public final class PermPlayer extends PermEntity {
|
||||
|
||||
/**
|
||||
* Tells if this player has been assigned to the default groups.
|
||||
* @return true if this player has been assigned to the default groups, or false if this player belongs explicitely
|
||||
* @return true if this player has been assigned to the default groups, or false if this player belongs explicitly
|
||||
* to their groups.
|
||||
*/
|
||||
public boolean isUsingDefaultGroups() {
|
||||
@@ -92,7 +92,7 @@ public final class PermPlayer extends PermEntity {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the group this player will now inheritate, removing all previously inherited groups.
|
||||
* Sets the group this player will now inherit, removing all previously inherited groups.
|
||||
* To keep the other inherited groups, use {@link #addGroup(String)}.
|
||||
* @param group the name of the group to inherit from.
|
||||
*/
|
||||
@@ -101,7 +101,7 @@ public final class PermPlayer extends PermEntity {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the group this player will now inheritate, removing all previously inherited groups.
|
||||
* Sets the group this player will now inherit, removing all previously inherited groups.
|
||||
* To keep the other inherited groups, use {@link #addGroup(PermGroup)}.
|
||||
* @param group the group to inherit from.
|
||||
*/
|
||||
@@ -110,7 +110,7 @@ public final class PermPlayer extends PermEntity {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes this player inherit the provided group, keeping the other groups they already inherits from.
|
||||
* Makes this player inherit the provided group, keeping the other groups they already inherit from.
|
||||
* @param group the name of the group to inherit from.
|
||||
*/
|
||||
public void addGroup(String group) {
|
||||
@@ -118,7 +118,7 @@ public final class PermPlayer extends PermEntity {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes this player inherit the provided group, keeping the other groups they already inherits from.
|
||||
* Makes this player inherit the provided group, keeping the other groups they already inherit from.
|
||||
* @param group the group to inherit from.
|
||||
*/
|
||||
public void addGroup(PermGroup group) {
|
||||
|
@@ -42,7 +42,7 @@ public class PermissionExpressionParser {
|
||||
* @throws IllegalArgumentException if the expression is not correct.
|
||||
* @return the result of the evaluation of the permission expression.
|
||||
*/
|
||||
public static boolean evaluate(String permString, LitteralPermissionTester permTester) {
|
||||
public static boolean evaluate(String permString, LiteralPermissionTester permTester) {
|
||||
try {
|
||||
return PERMISSION_EVALUATOR.evaluate(permString, permTester);
|
||||
} catch (IllegalArgumentException e) {
|
||||
@@ -53,7 +53,7 @@ public class PermissionExpressionParser {
|
||||
/**
|
||||
* Functional interface that converts a string into a boolean.
|
||||
*/
|
||||
public interface LitteralPermissionTester extends Function<String, Boolean> { }
|
||||
public interface LiteralPermissionTester extends Function<String, Boolean> { }
|
||||
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public class PermissionExpressionParser {
|
||||
protected Boolean toValue(String literal, Object evaluationContext) {
|
||||
if (literal.contains(" ") || literal.contains("|") || literal.contains("&"))
|
||||
throw new IllegalArgumentException("Unable to parse the following part of permission expression as one permission node: '" + literal + "'");
|
||||
return evaluationContext instanceof LitteralPermissionTester pt ? pt.apply(literal) : false;
|
||||
return evaluationContext instanceof LiteralPermissionTester pt ? pt.apply(literal) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -79,7 +79,7 @@ public class Permissions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all the cached data (players and groupds) and fetch all the groups data from the database.
|
||||
* Clears all the cached data (players and groups) and fetch all the groups' data from the database.
|
||||
* The clearing and fetching of the data is made asynchronously in a new thread.
|
||||
* @param then the action to perform after the cache has been updated.
|
||||
* @throws IllegalStateException if the permission system was not initialized properly.
|
||||
@@ -105,7 +105,7 @@ public class Permissions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks the permission system to preventively and asynchronoulsy cache the data of the provided player.
|
||||
* Asks the permission system to preventively and asynchronously cache the data of the provided player.
|
||||
* This can be called as soon as possible when a player connects, so the permission data of the player are
|
||||
* accessible as soon as possible when they are needed.
|
||||
* @param playerId the UUID of the player.
|
||||
|
@@ -303,9 +303,9 @@ import fr.pandacube.lib.util.Log;
|
||||
public final boolean deflt;
|
||||
public final List<CachedGroup> inheritances = new ArrayList<>();
|
||||
private CachedGroup(String n, String p, String s,
|
||||
boolean dflt, Map<ServerWorldKey, List<String>> perms) {
|
||||
boolean deflt, Map<ServerWorldKey, List<String>> perms) {
|
||||
super(n, p, s, perms);
|
||||
deflt = dflt;
|
||||
this.deflt = deflt;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -173,8 +173,8 @@ import fr.pandacube.lib.util.Log;
|
||||
ChatTreeNode node = new ChatTreeNode(c);
|
||||
|
||||
if (result == null && !conflict && !inheritances.isEmpty()) {
|
||||
// there is nothing interesting to show on current or subnode
|
||||
node.children.add(new ChatTreeNode(Chat.text("(Inheritances hidden for brevety)").darkGray().italic()));
|
||||
// there is nothing interesting to show on current or sub node
|
||||
node.children.add(new ChatTreeNode(Chat.text("(Inheritances hidden for brevity)").darkGray().italic()));
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -364,9 +364,9 @@ import fr.pandacube.lib.util.Log;
|
||||
.collect(Collectors.toCollection(() -> EnumSet.noneOf(PermState.class)));
|
||||
|
||||
boolean inheritancesGranted = inheritedPermissions.contains(PermState.GRANTED);
|
||||
boolean inheritancesRevoqued = inheritedPermissions.contains(PermState.REVOQUED);
|
||||
if (inheritancesGranted != inheritancesRevoqued) {
|
||||
resolutionNode.result = inheritancesGranted ? PermState.GRANTED : PermState.REVOQUED;
|
||||
boolean inheritancesRevoked = inheritedPermissions.contains(PermState.REVOKED);
|
||||
if (inheritancesGranted != inheritancesRevoked) {
|
||||
resolutionNode.result = inheritancesGranted ? PermState.GRANTED : PermState.REVOKED;
|
||||
}
|
||||
else if (inheritancesGranted) {
|
||||
resolutionNode.conflictMessage = (resolutionNode.conflictMessage == null ? "" : (resolutionNode.conflictMessage + " ; "))
|
||||
@@ -435,28 +435,28 @@ import fr.pandacube.lib.util.Log;
|
||||
|
||||
boolean explicitGranted = foundPerms.stream()
|
||||
.anyMatch(n -> n.type == PermType.EXPLICIT && n.result == Boolean.TRUE);
|
||||
boolean explicitRevoqued = foundPerms.stream()
|
||||
boolean explicitRevoked = foundPerms.stream()
|
||||
.anyMatch(n -> n.type == PermType.EXPLICIT && n.result == Boolean.FALSE);
|
||||
|
||||
boolean wildcardGranted = foundPerms.stream()
|
||||
.anyMatch(n -> n.type == PermType.WILDCARD && n.result == Boolean.TRUE);
|
||||
boolean wildcardRevoqued = foundPerms.stream()
|
||||
boolean wildcardRevoked = foundPerms.stream()
|
||||
.anyMatch(n -> n.type == PermType.WILDCARD && n.result == Boolean.FALSE);
|
||||
|
||||
if (explicitGranted != explicitRevoqued) {
|
||||
if (explicitGranted != explicitRevoked) {
|
||||
result = PermState.of(explicitGranted);
|
||||
if (!wildcardGranted && !wildcardRevoqued) { }
|
||||
else if (wildcardGranted && wildcardRevoqued) {
|
||||
if (!wildcardGranted && !wildcardRevoked) { }
|
||||
else if (wildcardGranted && wildcardRevoked) {
|
||||
conflict = "Self explicit permission defined but conflict between self wildcard permissions";
|
||||
}
|
||||
else if (explicitGranted == wildcardGranted) {
|
||||
conflict = "Unnecessary explicit permission already granted by self wildcard permissions"; // redundent explicit perm
|
||||
conflict = "Unnecessary explicit permission already granted by self wildcard permissions"; // redundant explicit perm
|
||||
}
|
||||
}
|
||||
else if (explicitGranted) {
|
||||
conflict = "Unsolvable conflit between explicit permissions";
|
||||
}
|
||||
else if (wildcardGranted != wildcardRevoqued) {
|
||||
else if (wildcardGranted != wildcardRevoked) {
|
||||
result = PermState.of(wildcardGranted);
|
||||
}
|
||||
else if (wildcardGranted) {
|
||||
@@ -500,8 +500,8 @@ import fr.pandacube.lib.util.Log;
|
||||
selfPermissions.forEach(p -> node.children.add(p.toDisplayTreeNode()));
|
||||
|
||||
if (result == PermState.UNDEFINED && !conflict && !inheritances.isEmpty()) {
|
||||
// there is nothing interesting to show on current or subnode
|
||||
node.children.add(new ChatTreeNode(Chat.text("(Inheritances hidden for brevety)").darkGray().italic()));
|
||||
// there is nothing interesting to show on current or sub node
|
||||
node.children.add(new ChatTreeNode(Chat.text("(Inheritances hidden for brevity)").darkGray().italic()));
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -551,12 +551,12 @@ import fr.pandacube.lib.util.Log;
|
||||
|
||||
private enum PermState {
|
||||
GRANTED(true),
|
||||
REVOQUED(false),
|
||||
REVOKED(false),
|
||||
UNDEFINED(null);
|
||||
final Boolean value;
|
||||
PermState(Boolean v) { value = v; }
|
||||
private static PermState of(Boolean v) {
|
||||
return v == null ? UNDEFINED : v ? GRANTED : REVOQUED;
|
||||
return v == null ? UNDEFINED : v ? GRANTED : REVOKED;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -9,7 +9,7 @@ import fr.pandacube.lib.db.SQLField;
|
||||
public class SQLPermissions extends SQLElement<SQLPermissions> {
|
||||
|
||||
/**
|
||||
* Instanciate a new entry in the table.
|
||||
* Instantiate a new entry in the table.
|
||||
*/
|
||||
public SQLPermissions() {
|
||||
super();
|
||||
|
@@ -1,16 +1,16 @@
|
||||
package fr.pandacube.lib.permissions;
|
||||
|
||||
import fr.pandacube.lib.permissions.PermissionExpressionParser.LitteralPermissionTester;
|
||||
import org.junit.Before;
|
||||
import fr.pandacube.lib.permissions.PermissionExpressionParser.LiteralPermissionTester;
|
||||
import org.junit.Test;
|
||||
|
||||
import static fr.pandacube.lib.permissions.PermissionExpressionParser.evaluate;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class PermissionExpressionParserTest {
|
||||
|
||||
java.util.List<String> pList = java.util.Arrays.asList("p1.cmd", "p1.toto", "p2.lol");
|
||||
LitteralPermissionTester tester = p -> pList.contains(p);
|
||||
final java.util.List<String> pList = java.util.Arrays.asList("p1.cmd", "p1.toto", "p2.lol");
|
||||
final LiteralPermissionTester tester = pList::contains;
|
||||
|
||||
@Test
|
||||
public void evaluateTrue() {
|
||||
|
Reference in New Issue
Block a user