component.setEnabled(false);
}
}
}
if (posixConfigured == true) {
add(new IFormValidator() {
@Override
public FormComponent< ? >[] getDependentFormComponents()
{
return dependentLdapPosixFormComponentsList.toArray(new FormComponent[0]);
}
@Override
public void validate(final Form< ? > form)
{
final LdapUserValues values = new LdapUserValues();
values.setUidNumber(uidNumberField.getConvertedInput());
values.setGidNumber(gidNumberField.getConvertedInput());
values.setHomeDirectory(homeDirectoryField.getConvertedInput());
values.setLoginShell(loginShellField.getConvertedInput());
if (StringUtils.isBlank(data.getLdapValues()) == true && values.isPosixValuesEmpty() == true) {
// Nothing to validate: all fields are zero and posix account wasn't set for this user before.
return;
}
if (values.getUidNumber() == null) {
uidNumberField.error(getLocalizedMessage(WebConstants.I18N_KEY_FIELD_REQUIRED, getString("ldap.uidNumber")));
} else {
if (LdapPosixAccountsUtils.isGivenNumberFree(data, values.getUidNumber()) == false) {
uidNumberField.error(getLocalizedMessage("ldap.uidNumber.alreadyInUse", LdapPosixAccountsUtils.getNextFreeUidNumber()));
}
}
if (values.getGidNumber() == null) {
gidNumberField.error(getLocalizedMessage(WebConstants.I18N_KEY_FIELD_REQUIRED, getString("ldap.gidNumber")));
}
if (StringUtils.isBlank(values.getHomeDirectory()) == true) {
homeDirectoryField.error(getLocalizedMessage(WebConstants.I18N_KEY_FIELD_REQUIRED, getString("ldap.homeDirectory")));
}
if (StringUtils.isBlank(values.getLoginShell()) == true) {
loginShellField.error(getLocalizedMessage(WebConstants.I18N_KEY_FIELD_REQUIRED, getString("ldap.loginShell")));
}
}
});
}
if (sambaConfigured == true) {
add(new IFormValidator() {
@Override
public FormComponent< ? >[] getDependentFormComponents()
{
return dependentLdapSambaFormComponentsList.toArray(new FormComponent[0]);
}