Skip to content
Snippets Groups Projects
Commit 6d6d9a6c authored by srosse's avatar srosse
Browse files

OO-4176: check length of name and identifier of organisations

parent 31c02499
No related branches found
No related tags found
No related merge requests found
...@@ -152,7 +152,6 @@ public class EditOrganisationController extends FormBasicController { ...@@ -152,7 +152,6 @@ public class EditOrganisationController extends FormBasicController {
organisationTypeEl.select(typeKeys[0], true); organisationTypeEl.select(typeKeys[0], true);
} }
String description = organisation == null ? "" : organisation.getDescription(); String description = organisation == null ? "" : organisation.getDescription();
descriptionEl = uifactory.addRichTextElementForStringDataCompact("organisation.description", "organisation.description", description, 10, 60, null, descriptionEl = uifactory.addRichTextElementForStringDataCompact("organisation.description", "organisation.description", description, 10, 60, null,
formLayout, ureq.getUserSession(), getWindowControl()); formLayout, ureq.getUserSession(), getWindowControl());
...@@ -171,21 +170,25 @@ public class EditOrganisationController extends FormBasicController { ...@@ -171,21 +170,25 @@ public class EditOrganisationController extends FormBasicController {
@Override @Override
protected boolean validateFormLogic(UserRequest ureq) { protected boolean validateFormLogic(UserRequest ureq) {
boolean allOk = super.validateFormLogic(ureq);
allOk &= validateTextfield(displayNameEl, 255, true);
allOk &= validateTextfield(identifierEl, 64, true);
return allOk;
}
private boolean validateTextfield(TextElement textEl, int maxSize, boolean mandatory) {
boolean allOk = true; boolean allOk = true;
displayNameEl.clearError(); textEl.clearError();
if(!StringHelper.containsNonWhitespace(displayNameEl.getValue())) { if(mandatory && !StringHelper.containsNonWhitespace(textEl.getValue())) {
displayNameEl.setErrorKey("form.legende.mandatory", null);
allOk &= false;
}
identifierEl.clearError();
if(!StringHelper.containsNonWhitespace(identifierEl.getValue())) {
identifierEl.setErrorKey("form.legende.mandatory", null); identifierEl.setErrorKey("form.legende.mandatory", null);
allOk &= false; allOk &= false;
} else if(textEl.getValue().length() >= maxSize) {
textEl.setErrorKey("form.error.toolong", new String[] { Integer.toString(maxSize) });
allOk &= false;
} }
return allOk & super.validateFormLogic(ureq); return allOk;
} }
@Override @Override
...@@ -194,7 +197,7 @@ public class EditOrganisationController extends FormBasicController { ...@@ -194,7 +197,7 @@ public class EditOrganisationController extends FormBasicController {
String selectedTypeKey = organisationTypeEl.getSelectedKey(); String selectedTypeKey = organisationTypeEl.getSelectedKey();
if(StringHelper.containsNonWhitespace(selectedTypeKey)) { if(StringHelper.containsNonWhitespace(selectedTypeKey)) {
organisationType = organisationService organisationType = organisationService
.getOrganisationType(new OrganisationTypeRefImpl(new Long(selectedTypeKey))); .getOrganisationType(new OrganisationTypeRefImpl(Long.valueOf(selectedTypeKey)));
} }
if(organisation == null) { if(organisation == null) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment