use of org.olat.portfolio.manager.EPMapPolicy.Type in project OpenOLAT by OpenOLAT.
the class EPShareListController method validateFormLogic.
@Override
protected boolean validateFormLogic(UserRequest ureq) {
boolean allOk = true;
// process all form-input fields and update data-model
secureListBox();
String genericError = null;
for (EPSharePolicyWrapper policyWrapper : policyWrappers) {
Type type = policyWrapper.getType();
if (type == null) {
// tutor implicit rule
continue;
}
TextElement mailEl = policyWrapper.getMailEl();
if (mailEl != null) {
String mail = mailEl.getValue();
if (StringHelper.containsNonWhitespace(mail)) {
if (MailHelper.isValidEmailAddress(mail)) {
SecurityGroup allUsers = securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS);
List<Identity> shareWithIdentities = userManager.findIdentitiesByEmail(Collections.singletonList(mail));
if (isAtLeastOneInSecurityGroup(shareWithIdentities, allUsers)) {
mailEl.setErrorKey("error.invitation.mail.used", new String[] { mail });
allOk &= false;
}
} else {
mailEl.setErrorKey("map.share.with.mail.error", null);
allOk &= false;
}
} else if (type.equals(Type.invitation)) {
genericError = translate("map.share.error.invite");
allOk &= false;
}
} else if (type.equals(Type.group)) {
List<BusinessGroup> groups = policyWrapper.getGroups();
if (groups.size() == 0) {
genericError = translate("map.share.error.group");
allOk &= false;
}
} else if (type.equals(Type.user)) {
List<Identity> idents = policyWrapper.getIdentities();
if (idents.size() == 0) {
genericError = translate("map.share.error.user");
allOk &= false;
}
}
if ((policyWrapper.getFromChooser() != null && policyWrapper.getFromChooser().hasError()) || (policyWrapper.getToChooser() != null && policyWrapper.getToChooser().hasError())) {
genericError = translate("map.share.date.invalid");
allOk &= false;
}
if (policyWrapper.getFrom() != null && policyWrapper.getTo() != null && policyWrapper.getFrom().after(policyWrapper.getTo())) {
// show invalid date warning
policyWrapper.getFromChooser().setErrorKey("from.date.behind.to", null);
policyWrapper.getFromChooser().showError(true);
genericError = translate("from.date.behind.to");
allOk &= false;
}
StaticTextElement errTextEl = policyWrapper.getErrorEl();
if (genericError != null && errTextEl != null) {
errTextEl.setValue(genericError);
}
}
return allOk && super.validateFormLogic(ureq);
}
use of org.olat.portfolio.manager.EPMapPolicy.Type in project openolat by klemens.
the class EPShareListController method validateFormLogic.
@Override
protected boolean validateFormLogic(UserRequest ureq) {
boolean allOk = true;
// process all form-input fields and update data-model
secureListBox();
String genericError = null;
for (EPSharePolicyWrapper policyWrapper : policyWrappers) {
Type type = policyWrapper.getType();
if (type == null) {
// tutor implicit rule
continue;
}
TextElement mailEl = policyWrapper.getMailEl();
if (mailEl != null) {
String mail = mailEl.getValue();
if (StringHelper.containsNonWhitespace(mail)) {
if (MailHelper.isValidEmailAddress(mail)) {
SecurityGroup allUsers = securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS);
List<Identity> shareWithIdentities = userManager.findIdentitiesByEmail(Collections.singletonList(mail));
if (isAtLeastOneInSecurityGroup(shareWithIdentities, allUsers)) {
mailEl.setErrorKey("error.invitation.mail.used", new String[] { mail });
allOk &= false;
}
} else {
mailEl.setErrorKey("map.share.with.mail.error", null);
allOk &= false;
}
} else if (type.equals(Type.invitation)) {
genericError = translate("map.share.error.invite");
allOk &= false;
}
} else if (type.equals(Type.group)) {
List<BusinessGroup> groups = policyWrapper.getGroups();
if (groups.size() == 0) {
genericError = translate("map.share.error.group");
allOk &= false;
}
} else if (type.equals(Type.user)) {
List<Identity> idents = policyWrapper.getIdentities();
if (idents.size() == 0) {
genericError = translate("map.share.error.user");
allOk &= false;
}
}
if ((policyWrapper.getFromChooser() != null && policyWrapper.getFromChooser().hasError()) || (policyWrapper.getToChooser() != null && policyWrapper.getToChooser().hasError())) {
genericError = translate("map.share.date.invalid");
allOk &= false;
}
if (policyWrapper.getFrom() != null && policyWrapper.getTo() != null && policyWrapper.getFrom().after(policyWrapper.getTo())) {
// show invalid date warning
policyWrapper.getFromChooser().setErrorKey("from.date.behind.to", null);
policyWrapper.getFromChooser().showError(true);
genericError = translate("from.date.behind.to");
allOk &= false;
}
StaticTextElement errTextEl = policyWrapper.getErrorEl();
if (genericError != null && errTextEl != null) {
errTextEl.setValue(genericError);
}
}
return allOk && super.validateFormLogic(ureq);
}
Aggregations