300 List<String> releasedAttributes =
new ArrayList<String>();
302 String mailMsgPlain =
"";
303 String mailMsgHtml =
"";
304 for (GluuCustomAttribute customAttribute : trustRelationship.getReleasedCustomAttributes()) {
305 if (customAttribute.isNew()) {
307 rendererParameters.setParameter(
"attributeDisplayName", customAttribute.getMetadata().getDisplayName());
310 mailMsgPlain +=
facesMessages.evalResourceAsString(
"#{msg['mail.trust.released.attribute.plain']}");
311 mailMsgHtml +=
facesMessages.evalResourceAsString(
"#{msg['mail.trust.released.attribute.html']}");
314 customAttribute.setNew(
false);
316 releasedAttributes.add(customAttribute.getMetadata().getDn());
320 if (!StringUtils.isEmpty(mailMsgPlain)) {
324 if (appliance.getContactEmail() == null || appliance.getContactEmail().isEmpty())
325 log.warn(
"Failed to send the 'Attributes released' notification email: unconfigured contact email");
326 else if (appliance.getSmtpConfiguration() == null
327 || StringHelper.isEmpty(appliance.getSmtpConfiguration().getHost()))
328 log.warn(
"Failed to send the 'Attributes released' notification email: unconfigured SMTP server");
330 String subj =
facesMessages.evalResourceAsString(
"#{msg['mail.trust.released.subject']}");
332 rendererParameters.setParameter(
"trustRelationshipName", trustRelationship.getDisplayName());
333 rendererParameters.setParameter(
"trustRelationshipInum", trustRelationship.getInum());
335 String preMsgPlain =
facesMessages.evalResourceAsString(
"#{msg['mail.trust.released.name.plain']}");
336 String preMsgHtml =
facesMessages.evalResourceAsString(
"#{msg['mail.trust.released.name.html']}");
342 boolean result =
mailService.sendMail(appliance.getContactEmail(), null, subj,
343 preMsgPlain + mailMsgPlain, preMsgHtml + mailMsgHtml);
346 log.error(
"Failed to send the notification email");
349 }
catch (Exception ex) {
350 log.error(
"Failed to send the notification email: ", ex);
354 if (!releasedAttributes.isEmpty()) {
355 trustRelationship.setReleasedAttributes(releasedAttributes);
357 trustRelationship.setReleasedAttributes(null);
GluuAppliance getAppliance(String[] returnAttributes)
Definition: ApplianceService.java:111
Logger log
Definition: TrustService.java:53
FacesMessages facesMessages
Definition: TrustService.java:56
MailService mailService
Definition: TrustService.java:74
ApplianceService applianceService
Definition: TrustService.java:65
RenderParameters rendererParameters
Definition: TrustService.java:77