Skip to content

Commit ffa219f

Browse files
committedJan 2, 2014
Fixed sonar blocker issue
1 parent 358de98 commit ffa219f

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed
 

‎api/src/main/java/org/openmrs/validator/UserValidator.java

+21-20
Original file line numberDiff line numberDiff line change
@@ -85,27 +85,28 @@ public void validate(Object obj, Errors errors) {
8585
if (person.getPersonName() == null || StringUtils.isEmpty(person.getPersonName().getFullName()))
8686
errors.rejectValue("person", "Person.names.length");
8787
}
88-
}
89-
AdministrationService as = Context.getAdministrationService();
90-
boolean emailAsUsername = false;
91-
try {
92-
Context.addProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES);
93-
emailAsUsername = Boolean.parseBoolean(as.getGlobalProperty(
94-
OpenmrsConstants.GLOBAL_PROPERTY_USER_REQUIRE_EMAIL_AS_USERNAME, "false"));
95-
}
96-
finally {
97-
Context.removeProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES);
98-
}
99-
100-
if (emailAsUsername) {
101-
boolean isValidUserName = isUserNameAsEmailValid(user.getUsername());
102-
if (!isValidUserName) {
103-
errors.rejectValue("username", "error.username.email");
88+
89+
AdministrationService as = Context.getAdministrationService();
90+
boolean emailAsUsername = false;
91+
try {
92+
Context.addProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES);
93+
emailAsUsername = Boolean.parseBoolean(as.getGlobalProperty(
94+
OpenmrsConstants.GLOBAL_PROPERTY_USER_REQUIRE_EMAIL_AS_USERNAME, "false"));
10495
}
105-
} else {
106-
boolean isValidUserName = isUserNameValid(user.getUsername());
107-
if (!isValidUserName) {
108-
errors.rejectValue("username", "error.username.pattern");
96+
finally {
97+
Context.removeProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES);
98+
}
99+
100+
if (emailAsUsername) {
101+
boolean isValidUserName = isUserNameAsEmailValid(user.getUsername());
102+
if (!isValidUserName) {
103+
errors.rejectValue("username", "error.username.email");
104+
}
105+
} else {
106+
boolean isValidUserName = isUserNameValid(user.getUsername());
107+
if (!isValidUserName) {
108+
errors.rejectValue("username", "error.username.pattern");
109+
}
109110
}
110111
}
111112
}

1 commit comments

Comments
 (1)

djazayeri commented on Jan 2, 2014

@djazayeri
Member

Remember to include ticket numbers in your commit comments. :-)

Please sign in to comment.