/** * Role group names mostly follow the same conventions as role names. The only difference is that the role group * "_" is a reserved null-substitution for the absence of a group. */ public static boolean isLegalRoleGroupName(String group) { return isLegalRoleName(group) && !"_".equals(group); } }
/** * Table names must be lowercase ASCII strings. between 1 and 255 characters in length. Whitespace, ISO control * characters and certain punctuation characters that aren't generally allowed in file names or in elasticsearch * index names are excluded (elasticsearch appears to allow: !$%&()+-.:;=@[]^_`{}~). Table names may not begin * with a single underscore to allow URL space for extensions such as "/_table/...". */ public static boolean isLegalTableName(String table) { return com.bazaarvoice.emodb.common.api.Names.isLegalTableName(table); }
private String checkGroup(@Nullable String group) { // Role groups follow the same naming conventions as role names checkArgument(group == null || isLegalRoleGroupName(group), "Group cannot be named %s", group); // Since legal role group names cannot equal "_" if the previous check passed then there cannot be a conflict return group == null ? NO_GROUP_NAME : group; }
/** * Role group names mostly follow the same conventions as role names. The only difference is that the role group * "_" is a reserved null-substitution for the absence of a group. */ public static boolean isLegalRoleGroupName(String group) { return isLegalRoleName(group) && !"_".equals(group); } }
public static boolean isLegalTableName(String table) { return com.bazaarvoice.emodb.common.api.Names.isLegalTableName(table); }
private String checkGroup(@Nullable String group) { // Role groups follow the same naming conventions as role names checkArgument(group == null || isLegalRoleGroupName(group), "Group cannot be named %s", group); // Since legal role group names cannot equal "_" if the previous check passed then there cannot be a conflict return group == null ? NO_GROUP_NAME : group; }
@Override public Role createRole(RoleIdentifier id, RoleModification modification) { checkNotNull(id, "id"); checkArgument(isLegalRoleName(id.getId()), "Role cannot have ID %s", id.getId()); String groupKey = checkGroup(id.getGroup());
public static boolean isLegalTableName(String table) { return com.bazaarvoice.emodb.common.api.Names.isLegalTableName(table); }
@Override public Role createRole(RoleIdentifier id, RoleModification modification) { checkNotNull(id, "id"); checkArgument(isLegalRoleName(id.getId()), "Role cannot have ID %s", id.getId()); String groupKey = checkGroup(id.getGroup());
/** * Parses a string in the format "<table>/<id>". This is the inverse of {@link #toString()}. */ public static Coordinate parse(String string) { checkNotNull(string, "string"); int delim = string.indexOf('/'); checkArgument(delim != -1, "Invalid coordinate format."); String table = string.substring(0, delim); String id = string.substring(delim + 1); checkArgument(com.bazaarvoice.emodb.common.api.Names.isLegalTableName(table), "Invalid coordinate format: invalid table name"); checkArgument(!id.isEmpty(), "Invalid coordinate format: missing identifier"); return new Coordinate(table, id); }