+ private int notify(AuthzTrans trans, NotifyBody nb) {
+ List<String> toList = new ArrayList<>();
+ List<String> ccList = new ArrayList<>();
+ List<String> idList = new ArrayList<>();
+
+ String run = nb.type()+nb.name();
+ String test = dryRun?run:null;
+
+ ONE_EMAIL:
+ for(String id : nb.users()) {
+ toList.clear();
+ ccList.clear();
+ idList.clear();
+ try {
+ List<Identity> identities = trans.org().getIDs(trans, id, nb.escalation());
+ if(identities.isEmpty()) {
+ trans.warn().printf("%s is invalid for this Organization. Skipping notification.",id);
+ } else {
+ Identity identity = null;
+ for(Identity ident : identities) {
+ if(identity==null) {
+ identity = ident;
+ toList.add(ident.email());
+ } else {
+ ccList.add(ident.email());
+ }
+ idList.add(ident.fullID());
+ }
+ StringBuilder content = new StringBuilder();
+ content.append(String.format(header,version,Identity.mixedCase(identity.firstName())));
+
+ nb.body(trans, content, indent, this, id);
+ content.append(footer);
+
+ if(mailer.sendEmail(trans, test, toList, ccList, nb.subject(),content.toString(), urgent)) {
+ cbl.preLoop();
+ nb.record(trans,cbl.inc(), id, idList, lastN);
+ nb.inc();
+ } else {
+ trans.error().log("Mailer failed to send Mail");
+ }
+ if(maxEmails>0 && nb.count()>=maxEmails) {
+ break ONE_EMAIL;
+ }
+ }
+ } catch (OrganizationException e) {
+ trans.error().log(e);
+ }
+ }
+ cbl.flush();
+ return nb.count();