Optimize USER_NAME_PATTERN string and its usage
The following issues from [1] are addressed by this change: 1. common pattern part was extracted 2. USER_NAME_PATTERN string is used to indicate that account couldn't have been created as it is not compliant with it 3. number of lines was reduced in USER_NAME_PATTERN by combining relevant characters together In addition: USER_NAME_PATTERN_LAST is derived from USER_NAME_PATTERN_FIRST as they are equal. [1] https://gerrit-review.googlesource.com/c/gerrit/+/194650 Change-Id: I02ce9c6b6d3b121050178851e2121b3419e7b830 Signed-off-by: Jacek Centkowski <jcentkowski@collab.net>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.account;
|
||||
|
||||
import static com.google.gerrit.reviewdb.client.Account.USER_NAME_PATTERN;
|
||||
import static com.google.gerrit.server.account.ExternalId.SCHEME_MAILTO;
|
||||
|
||||
import com.google.gerrit.audit.AuditService;
|
||||
@@ -113,7 +114,7 @@ public class CreateAccount implements RestModifyView<TopLevelResource, AccountIn
|
||||
|
||||
if (!username.matches(Account.USER_NAME_PATTERN)) {
|
||||
throw new BadRequestException(
|
||||
"Username '" + username + "' must contain only letters, numbers, _, - or .");
|
||||
"Username '" + username + "' must comply with [" + USER_NAME_PATTERN + "] pattern.");
|
||||
}
|
||||
|
||||
Set<AccountGroup.Id> groups = parseGroups(input.groups);
|
||||
|
||||
Reference in New Issue
Block a user