public static Group getGroup(String name) { for (Group group : groups) { if (group.getName().equalsIgnoreCase(name)) { return group; } } return null; }
public static void saveGroups() { MongoCollection<Document> collection = MongoConnection.getCollection("perms", "groups"); for (Group group : groups) { collection.replaceOne( eq("group", group.getName()), new Document("group", group.getName()) .append("permissions", group.permissions) .append("inherits", group.inherits)); } }
public void removeInheritance(Group group) { inherits.remove(group.getName()); MongoCollection<Document> collection = MongoConnection.getCollection("perms", "groups"); Document doc = collection.find(eq("group", name)).first(); doc.put("inherits", inherits); collection.replaceOne(eq("group", name), doc); }