use of cz.metacentrum.perun.core.api.exceptions.PasswordResetMailNotExistsException in project perun by CESNET.
the class MembersManagerEntry method sendAccountActivationLinkEmail.
@Override
public void sendAccountActivationLinkEmail(PerunSession sess, Member member, String namespace, String url, String mailAttributeUrn, String language) throws PrivilegeException, MemberNotExistsException, UserNotExistsException, AttributeNotExistsException, PasswordResetMailNotExistsException {
Utils.checkPerunSession(sess);
getMembersManagerBl().checkMemberExists(sess, member);
// Authorization
if (!AuthzResolver.authorizedInternal(sess, "sendAccountActivationLinkEmail_Member_String_String_String_String_policy", member)) {
throw new PrivilegeException(sess, "sendAccountActivationLinkEmail");
}
// check if attribute exists, throws AttributeNotExistsException
Attribute mailAttribute = null;
AttributeDefinition attributeDefinition = getPerunBl().getAttributesManager().getAttributeDefinition(sess, mailAttributeUrn);
try {
if (attributeDefinition.getEntity().equals("user")) {
User user = perunBl.getUsersManagerBl().getUserByMember(sess, member);
mailAttribute = getPerunBl().getAttributesManagerBl().getAttribute(sess, user, mailAttributeUrn);
}
if (attributeDefinition.getEntity().equals("member")) {
mailAttribute = getPerunBl().getAttributesManagerBl().getAttribute(sess, member, mailAttributeUrn);
}
} catch (WrongAttributeAssignmentException ex) {
throw new InternalErrorException(ex);
}
if (mailAttribute == null) {
throw new InternalErrorException("MailAttribute should not be null.");
}
String mailAddress = mailAttribute.valueAsString();
if (mailAddress == null) {
throw new PasswordResetMailNotExistsException("Member " + member.getId() + " doesn't have the attribute " + mailAttributeUrn + " set.");
}
getMembersManagerBl().sendAccountActivationLinkEmail(sess, member, namespace, url, mailAddress, language);
}
use of cz.metacentrum.perun.core.api.exceptions.PasswordResetMailNotExistsException in project perun by CESNET.
the class MembersManagerEntry method sendPasswordResetLinkEmail.
@Override
public void sendPasswordResetLinkEmail(PerunSession sess, Member member, String namespace, String url, String mailAttributeUrn, String language) throws PrivilegeException, MemberNotExistsException, UserNotExistsException, AttributeNotExistsException, PasswordResetMailNotExistsException {
Utils.checkPerunSession(sess);
getMembersManagerBl().checkMemberExists(sess, member);
// Authorization
if (!AuthzResolver.authorizedInternal(sess, "sendPasswordResetLinkEmail_Member_String_String_String_String_policy", member)) {
throw new PrivilegeException(sess, "sendPasswordResetLinkEmail");
}
// check if attribute exists, throws AttributeNotExistsException
Attribute mailAttribute = null;
AttributeDefinition ad = getPerunBl().getAttributesManager().getAttributeDefinition(sess, mailAttributeUrn);
try {
if (ad.getEntity().equals("user")) {
User user = perunBl.getUsersManagerBl().getUserByMember(sess, member);
mailAttribute = getPerunBl().getAttributesManagerBl().getAttribute(sess, user, mailAttributeUrn);
}
if (ad.getEntity().equals("member")) {
mailAttribute = getPerunBl().getAttributesManagerBl().getAttribute(sess, member, mailAttributeUrn);
}
} catch (WrongAttributeAssignmentException ex) {
throw new InternalErrorException(ex);
}
if (mailAttribute == null) {
throw new InternalErrorException("MailAttribute should not be null.");
}
String mailAddress = mailAttribute.valueAsString();
if (mailAddress == null) {
throw new PasswordResetMailNotExistsException("Member " + member.getId() + " doesn't have the attribute " + mailAttributeUrn + " set.");
}
getMembersManagerBl().sendPasswordResetLinkEmail(sess, member, namespace, url, mailAddress, language);
}
Aggregations