blob: 5fea4922f5b7dbe9d3334ef1b95b8541bd572160 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>USERFRIENDLYSMTPNotifier.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">jUDDI Core Services</a> &gt; <a href="index.source.html" class="el_package">org.apache.juddi.subscription.notify</a> &gt; <span class="el_source">USERFRIENDLYSMTPNotifier.java</span></div><h1>USERFRIENDLYSMTPNotifier.java</h1><pre class="source lang-java linenums">/*
* Copyright 2001-2008 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.juddi.subscription.notify;
import java.io.StringWriter;
import java.net.URISyntaxException;
import java.rmi.RemoteException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.mail.Address;
import javax.mail.Message.RecipientType;
import javax.mail.Multipart;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.xml.bind.JAXB;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.juddi.config.AppConfig;
import org.apache.juddi.config.Property;
import org.apache.juddi.config.ResourceConfig;
import org.apache.juddi.cryptor.CryptorFactory;
import org.apache.juddi.jaxb.JAXBMarshaller;
import org.apache.juddi.mapping.MappingModelToApi;
import org.apache.juddi.model.BindingTemplate;
import org.apache.juddi.model.Publisher;
import org.apache.juddi.model.Subscription;
import org.uddi.api_v3.DispositionReport;
import org.uddi.api_v3.Result;
import org.uddi.sub_v3.SubscriptionFilter;
import org.uddi.sub_v3.SubscriptionResultsList;
import org.uddi.subr_v3.NotifySubscriptionListener;
import org.uddi.v3_service.DispositionReportFaultMessage;
/**
* This class extends the default SMTP notifier The following properties can be
* set in the juddiv3.xml, or as System params.
*
* &quot;mail.smtp.from&quot;, &quot;mail.smtp.host&quot;, &quot;mail.smtp.port&quot;,
* &quot;mail.smtp.socketFactory.class&quot;, &quot;mail.smtp.socketFactory.fallback&quot;,
* &quot;mail.smtp.starttls.enable&quot;,
* &quot;mail.smtp.socketFactory.port&quot;,&quot;mail.smtp.auth&quot;,&quot;mail.smtp.user&quot;,&quot;mail.smtp.password&quot;
*
* The following properties can be set juddiv3.xml.
*
* @author Kurt Stam
* @author Alex O'Ree
*/
public class USERFRIENDLYSMTPNotifier extends SMTPNotifier {
public static void notifySubscriptionDeleted(TemporaryMailContainer container) {
try {
<span class="nc" id="L78"> Publisher publisher = container.getPublisher();</span>
<span class="nc" id="L79"> Publisher deletedBy = container.getDeletedBy();</span>
<span class="nc" id="L80"> Subscription obj = container.getObj();</span>
<span class="nc" id="L81"> String emailaddress = publisher.getEmailAddress();</span>
<span class="nc bnc" id="L82" title="All 4 branches missed."> if (emailaddress==null || emailaddress.trim().equals(&quot;&quot;))</span>
<span class="nc" id="L83"> return;</span>
<span class="nc" id="L84"> Properties properties = new Properties();</span>
<span class="nc" id="L85"> Session session = null;</span>
<span class="nc" id="L86"> String mailPrefix = AppConfig.getConfiguration().getString(Property.JUDDI_EMAIL_PREFIX, Property.DEFAULT_JUDDI_EMAIL_PREFIX);</span>
<span class="nc bnc" id="L87" title="All 2 branches missed."> if (!mailPrefix.endsWith(&quot;.&quot;)) {</span>
<span class="nc" id="L88"> mailPrefix = mailPrefix + &quot;.&quot;;</span>
}
<span class="nc bnc" id="L90" title="All 2 branches missed."> for (String key : mailProps) {</span>
<span class="nc bnc" id="L91" title="All 2 branches missed."> if (AppConfig.getConfiguration().containsKey(mailPrefix + key)) {</span>
<span class="nc" id="L92"> properties.put(key, AppConfig.getConfiguration().getProperty(mailPrefix + key));</span>
<span class="nc bnc" id="L93" title="All 2 branches missed."> } else if (System.getProperty(mailPrefix + key) != null) {</span>
<span class="nc" id="L94"> properties.put(key, System.getProperty(mailPrefix + key));</span>
}
}
<span class="nc" id="L98"> boolean auth = (properties.getProperty(&quot;mail.smtp.auth&quot;, &quot;false&quot;)).equalsIgnoreCase(&quot;true&quot;);</span>
<span class="nc bnc" id="L99" title="All 2 branches missed."> if (auth) {</span>
<span class="nc" id="L100"> final String username = properties.getProperty(&quot;mail.smtp.user&quot;);</span>
<span class="nc" id="L101"> String pwd = properties.getProperty(&quot;mail.smtp.password&quot;);</span>
//decrypt if possible
<span class="nc bnc" id="L103" title="All 2 branches missed."> if (properties.getProperty(&quot;mail.smtp.password&quot; + Property.ENCRYPTED_ATTRIBUTE, &quot;false&quot;).equalsIgnoreCase(&quot;true&quot;)) {</span>
try {
<span class="nc" id="L105"> pwd = CryptorFactory.getCryptor().decrypt(pwd);</span>
<span class="nc" id="L106"> } catch (NoSuchPaddingException ex) {</span>
<span class="nc" id="L107"> log.error(&quot;Unable to decrypt settings&quot;, ex);</span>
<span class="nc" id="L108"> } catch (NoSuchAlgorithmException ex) {</span>
<span class="nc" id="L109"> log.error(&quot;Unable to decrypt settings&quot;, ex);</span>
<span class="nc" id="L110"> } catch (InvalidAlgorithmParameterException ex) {</span>
<span class="nc" id="L111"> log.error(&quot;Unable to decrypt settings&quot;, ex);</span>
<span class="nc" id="L112"> } catch (InvalidKeyException ex) {</span>
<span class="nc" id="L113"> log.error(&quot;Unable to decrypt settings&quot;, ex);</span>
<span class="nc" id="L114"> } catch (IllegalBlockSizeException ex) {</span>
<span class="nc" id="L115"> log.error(&quot;Unable to decrypt settings&quot;, ex);</span>
<span class="nc" id="L116"> } catch (BadPaddingException ex) {</span>
<span class="nc" id="L117"> log.error(&quot;Unable to decrypt settings&quot;, ex);</span>
<span class="nc" id="L118"> }</span>
}
<span class="nc" id="L120"> final String password = pwd;</span>
<span class="nc" id="L121"> log.debug(&quot;SMTP username = &quot; + username + &quot; from address = &quot; + emailaddress);</span>
<span class="nc" id="L122"> Properties eMailProperties = properties;</span>
<span class="nc" id="L123"> eMailProperties.remove(&quot;mail.smtp.user&quot;);</span>
<span class="nc" id="L124"> eMailProperties.remove(&quot;mail.smtp.password&quot;);</span>
<span class="nc" id="L125"> session = Session.getInstance(properties, new javax.mail.Authenticator() {</span>
protected PasswordAuthentication getPasswordAuthentication() {
<span class="nc" id="L127"> return new PasswordAuthentication(username, password);</span>
}
});
<span class="nc" id="L130"> } else {</span>
<span class="nc" id="L131"> Properties eMailProperties = properties;</span>
<span class="nc" id="L132"> eMailProperties.remove(&quot;mail.smtp.user&quot;);</span>
<span class="nc" id="L133"> eMailProperties.remove(&quot;mail.smtp.password&quot;);</span>
<span class="nc" id="L134"> session = Session.getInstance(eMailProperties);</span>
}
<span class="nc" id="L137"> MimeMessage message = new MimeMessage(session);</span>
<span class="nc" id="L138"> InternetAddress address = new InternetAddress(emailaddress);</span>
<span class="nc" id="L139"> Address[] to = {address};</span>
<span class="nc" id="L140"> message.setRecipients(RecipientType.TO, to);</span>
<span class="nc" id="L141"> message.setFrom(new InternetAddress(properties.getProperty(&quot;mail.smtp.from&quot;, &quot;jUDDI&quot;)));</span>
//Hello %s,&lt;br&gt;&lt;br&gt;Your subscription UDDI subscription was deleted. Attached is what the subscription was. It was deleted by %s, %s at %s. This node is %s
//maybe nice to use a template rather then sending raw xml.
<span class="nc" id="L144"> org.uddi.sub_v3.Subscription api = new org.uddi.sub_v3.Subscription();</span>
<span class="nc" id="L145"> MappingModelToApi.mapSubscription(obj, api);</span>
<span class="nc" id="L146"> String subscriptionResultXML = JAXBMarshaller.marshallToString(api, JAXBMarshaller.PACKAGE_SUBSCR_RES);</span>
<span class="nc" id="L147"> Multipart mp = new MimeMultipart();</span>
<span class="nc" id="L149"> MimeBodyPart content = new MimeBodyPart();</span>
<span class="nc" id="L150"> String msg_content = ResourceConfig.getGlobalMessage(&quot;notifications.smtp.subscriptionDeleted&quot;);</span>
<span class="nc" id="L151"> SimpleDateFormat sdf = new SimpleDateFormat(&quot;yyyy-MM-dd kk:mm:ssZ&quot;);</span>
//Hello %s, %s&lt;br&gt;&lt;br&gt;Your subscription UDDI subscription was deleted. Attached is what the subscription was. It was deleted by %s, %s at %s. This node is %s.
<span class="nc" id="L153"> msg_content = String.format(msg_content,</span>
<span class="nc" id="L154"> StringEscapeUtils.escapeHtml(publisher.getPublisherName()),</span>
<span class="nc" id="L155"> StringEscapeUtils.escapeHtml(publisher.getAuthorizedName()),</span>
<span class="nc" id="L156"> StringEscapeUtils.escapeHtml(deletedBy.getPublisherName()),</span>
<span class="nc" id="L157"> StringEscapeUtils.escapeHtml(deletedBy.getAuthorizedName()),</span>
<span class="nc" id="L158"> StringEscapeUtils.escapeHtml(sdf.format(new Date())),</span>
<span class="nc" id="L159"> StringEscapeUtils.escapeHtml(AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ID, &quot;(unknown node id!)&quot;)),</span>
<span class="nc" id="L160"> AppConfig.getConfiguration().getString(Property.JUDDI_BASE_URL, &quot;(unknown url)&quot;),</span>
<span class="nc" id="L161"> AppConfig.getConfiguration().getString(Property.JUDDI_BASE_URL_SECURE, &quot;(unknown url)&quot;)</span>
);
<span class="nc" id="L164"> content.setContent(msg_content, &quot;text/html; charset=UTF-8;&quot;);</span>
<span class="nc" id="L165"> mp.addBodyPart(content);</span>
<span class="nc" id="L167"> MimeBodyPart attachment = new MimeBodyPart();</span>
<span class="nc" id="L168"> attachment.setContent(subscriptionResultXML, &quot;text/xml; charset=UTF-8;&quot;);</span>
<span class="nc" id="L169"> attachment.setFileName(&quot;uddiNotification.xml&quot;);</span>
<span class="nc" id="L170"> mp.addBodyPart(attachment);</span>
<span class="nc" id="L172"> message.setContent(mp);</span>
<span class="nc" id="L173"> message.setSubject(ResourceConfig.getGlobalMessage(&quot;notifications.smtp.userfriendly.subject&quot;) + &quot; &quot;</span>
<span class="nc" id="L174"> + StringEscapeUtils.escapeHtml(obj.getSubscriptionKey()));</span>
<span class="nc" id="L175"> Transport.send(message);</span>
<span class="nc" id="L177"> } catch (Throwable t) {</span>
<span class="nc" id="L178"> log.warn(&quot;Error sending email!&quot; + t.getMessage());</span>
<span class="nc" id="L179"> log.debug(&quot;Error sending email!&quot; + t.getMessage(),t);</span>
<span class="nc" id="L180"> }</span>
<span class="nc" id="L181"> }</span>
public static void notifyAccountDeleted(TemporaryMailContainer container) {
try {
<span class="fc" id="L185"> Publisher publisher = container.getPublisher();</span>
<span class="fc" id="L186"> Publisher deletedBy = container.getDeletedBy();</span>
<span class="fc" id="L187"> String emailaddress = publisher.getEmailAddress();</span>
<span class="pc bpc" id="L188" title="2 of 4 branches missed."> if (emailaddress==null || emailaddress.trim().equals(&quot;&quot;))</span>
<span class="nc" id="L189"> return;</span>
<span class="fc" id="L190"> Properties properties = new Properties();</span>
<span class="fc" id="L191"> Session session = null;</span>
<span class="fc" id="L192"> String mailPrefix = AppConfig.getConfiguration().getString(Property.JUDDI_EMAIL_PREFIX, Property.DEFAULT_JUDDI_EMAIL_PREFIX);</span>
<span class="pc bpc" id="L193" title="1 of 2 branches missed."> if (!mailPrefix.endsWith(&quot;.&quot;)) {</span>
<span class="nc" id="L194"> mailPrefix = mailPrefix + &quot;.&quot;;</span>
}
<span class="fc bfc" id="L196" title="All 2 branches covered."> for (String key : mailProps) {</span>
<span class="pc bpc" id="L197" title="1 of 2 branches missed."> if (AppConfig.getConfiguration().containsKey(mailPrefix + key)) {</span>
<span class="nc" id="L198"> properties.put(key, AppConfig.getConfiguration().getProperty(mailPrefix + key));</span>
<span class="pc bpc" id="L199" title="1 of 2 branches missed."> } else if (System.getProperty(mailPrefix + key) != null) {</span>
<span class="nc" id="L200"> properties.put(key, System.getProperty(mailPrefix + key));</span>
}
}
<span class="fc" id="L204"> boolean auth = (properties.getProperty(&quot;mail.smtp.auth&quot;, &quot;false&quot;)).equalsIgnoreCase(&quot;true&quot;);</span>
<span class="pc bpc" id="L205" title="1 of 2 branches missed."> if (auth) {</span>
<span class="nc" id="L206"> final String username = properties.getProperty(&quot;mail.smtp.user&quot;);</span>
<span class="nc" id="L207"> String pwd = properties.getProperty(&quot;mail.smtp.password&quot;);</span>
//decrypt if possible
<span class="nc bnc" id="L209" title="All 2 branches missed."> if (properties.getProperty(&quot;mail.smtp.password&quot; + Property.ENCRYPTED_ATTRIBUTE, &quot;false&quot;).equalsIgnoreCase(&quot;true&quot;)) {</span>
try {
<span class="nc" id="L211"> pwd = CryptorFactory.getCryptor().decrypt(pwd);</span>
<span class="nc" id="L212"> } catch (NoSuchPaddingException ex) {</span>
<span class="nc" id="L213"> log.error(&quot;Unable to decrypt settings&quot;, ex);</span>
<span class="nc" id="L214"> } catch (NoSuchAlgorithmException ex) {</span>
<span class="nc" id="L215"> log.error(&quot;Unable to decrypt settings&quot;, ex);</span>
<span class="nc" id="L216"> } catch (InvalidAlgorithmParameterException ex) {</span>
<span class="nc" id="L217"> log.error(&quot;Unable to decrypt settings&quot;, ex);</span>
<span class="nc" id="L218"> } catch (InvalidKeyException ex) {</span>
<span class="nc" id="L219"> log.error(&quot;Unable to decrypt settings&quot;, ex);</span>
<span class="nc" id="L220"> } catch (IllegalBlockSizeException ex) {</span>
<span class="nc" id="L221"> log.error(&quot;Unable to decrypt settings&quot;, ex);</span>
<span class="nc" id="L222"> } catch (BadPaddingException ex) {</span>
<span class="nc" id="L223"> log.error(&quot;Unable to decrypt settings&quot;, ex);</span>
<span class="nc" id="L224"> }</span>
}
<span class="nc" id="L226"> final String password = pwd;</span>
<span class="nc" id="L227"> log.debug(&quot;SMTP username = &quot; + username + &quot; from address = &quot; + emailaddress);</span>
<span class="nc" id="L228"> Properties eMailProperties = properties;</span>
<span class="nc" id="L229"> eMailProperties.remove(&quot;mail.smtp.user&quot;);</span>
<span class="nc" id="L230"> eMailProperties.remove(&quot;mail.smtp.password&quot;);</span>
<span class="nc" id="L231"> session = Session.getInstance(properties, new javax.mail.Authenticator() {</span>
protected PasswordAuthentication getPasswordAuthentication() {
<span class="nc" id="L233"> return new PasswordAuthentication(username, password);</span>
}
});
<span class="nc" id="L236"> } else {</span>
<span class="fc" id="L237"> Properties eMailProperties = properties;</span>
<span class="fc" id="L238"> eMailProperties.remove(&quot;mail.smtp.user&quot;);</span>
<span class="fc" id="L239"> eMailProperties.remove(&quot;mail.smtp.password&quot;);</span>
<span class="fc" id="L240"> session = Session.getInstance(eMailProperties);</span>
}
<span class="fc" id="L243"> MimeMessage message = new MimeMessage(session);</span>
<span class="fc" id="L244"> InternetAddress address = new InternetAddress(emailaddress);</span>
<span class="fc" id="L245"> Address[] to = {address};</span>
<span class="fc" id="L246"> message.setRecipients(RecipientType.TO, to);</span>
<span class="fc" id="L247"> message.setFrom(new InternetAddress(properties.getProperty(&quot;mail.smtp.from&quot;, &quot;jUDDI&quot;)));</span>
//Hello %s,&lt;br&gt;&lt;br&gt;Your subscription UDDI subscription was deleted. Attached is what the subscription was. It was deleted by %s, %s at %s. This node is %s
<span class="fc" id="L250"> Multipart mp = new MimeMultipart();</span>
<span class="fc" id="L252"> MimeBodyPart content = new MimeBodyPart();</span>
<span class="fc" id="L253"> String msg_content = ResourceConfig.getGlobalMessage(&quot;notifications.smtp.accountDeleted&quot;);</span>
<span class="fc" id="L254"> SimpleDateFormat sdf = new SimpleDateFormat(&quot;yyyy-MM-dd kk:mm:ssZ&quot;);</span>
//Hello %s, %s,&lt;br&gt;&lt;br&gt;Your account has been deleted by %s, %s at %s. This node is %s.
<span class="fc" id="L256"> msg_content = String.format(msg_content,</span>
<span class="fc" id="L257"> StringEscapeUtils.escapeHtml(publisher.getPublisherName()),</span>
<span class="fc" id="L258"> StringEscapeUtils.escapeHtml(publisher.getAuthorizedName()),</span>
<span class="fc" id="L259"> StringEscapeUtils.escapeHtml(deletedBy.getPublisherName()),</span>
<span class="fc" id="L260"> StringEscapeUtils.escapeHtml(deletedBy.getAuthorizedName()),</span>
<span class="fc" id="L261"> StringEscapeUtils.escapeHtml(sdf.format(new Date())),</span>
<span class="fc" id="L262"> StringEscapeUtils.escapeHtml(AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ID, &quot;(unknown node id!)&quot;)),</span>
<span class="fc" id="L263"> AppConfig.getConfiguration().getString(Property.JUDDI_BASE_URL, &quot;(unknown url)&quot;),</span>
<span class="fc" id="L264"> AppConfig.getConfiguration().getString(Property.JUDDI_BASE_URL_SECURE, &quot;(unknown url)&quot;)</span>
);
<span class="fc" id="L267"> content.setContent(msg_content, &quot;text/html; charset=UTF-8;&quot;);</span>
<span class="fc" id="L268"> mp.addBodyPart(content);</span>
<span class="fc" id="L270"> message.setContent(mp);</span>
<span class="fc" id="L271"> message.setSubject(ResourceConfig.getGlobalMessage(&quot;notifications.smtp.accountDeleted.subject&quot;));</span>
<span class="nc" id="L272"> Transport.send(message);</span>
<span class="fc" id="L274"> } catch (Throwable t) {</span>
<span class="fc" id="L275"> log.warn(&quot;Error sending email!&quot; + t.getMessage());</span>
<span class="fc" id="L276"> log.debug(&quot;Error sending email!&quot; + t.getMessage(), t);</span>
<span class="nc" id="L277"> }</span>
<span class="fc" id="L278"> }</span>
public USERFRIENDLYSMTPNotifier(BindingTemplate bindingTemplate) throws URISyntaxException, Exception {
<span class="nc" id="L281"> super(bindingTemplate);</span>
<span class="nc" id="L282"> publisherName = bindingTemplate.getAuthorizedName();</span>
<span class="nc" id="L283"> }</span>
String publisherName;
@Override
public DispositionReport notifySubscriptionListener(NotifySubscriptionListener body) throws DispositionReportFaultMessage, RemoteException {
try {
<span class="nc" id="L291"> log.info(&quot;Sending notification email to &quot; + notificationEmailAddress + &quot; from &quot; + getEMailProperties().getProperty(&quot;mail.smtp.from&quot;, &quot;jUDDI&quot;));</span>
<span class="nc bnc" id="L292" title="All 4 branches missed."> if (session != null &amp;&amp; notificationEmailAddress != null) {</span>
<span class="nc" id="L293"> MimeMessage message = new MimeMessage(session);</span>
<span class="nc" id="L294"> InternetAddress address = new InternetAddress(notificationEmailAddress);</span>
<span class="nc" id="L295"> Address[] to = {address};</span>
<span class="nc" id="L296"> message.setRecipients(RecipientType.TO, to);</span>
<span class="nc" id="L297"> message.setFrom(new InternetAddress(getEMailProperties().getProperty(&quot;mail.smtp.from&quot;, &quot;jUDDI&quot;)));</span>
//maybe nice to use a template rather then sending raw xml.
<span class="nc" id="L299"> String subscriptionResultXML = JAXBMarshaller.marshallToString(body, JAXBMarshaller.PACKAGE_SUBSCR_RES);</span>
<span class="nc" id="L300"> Multipart mp = new MimeMultipart();</span>
<span class="nc" id="L302"> MimeBodyPart content = new MimeBodyPart();</span>
<span class="nc" id="L303"> String msg_content = ResourceConfig.getGlobalMessage(&quot;notifications.smtp.userfriendly.body&quot;);</span>
<span class="nc" id="L305"> msg_content = String.format(msg_content,</span>
<span class="nc" id="L306"> StringEscapeUtils.escapeHtml(this.publisherName),</span>
<span class="nc" id="L307"> StringEscapeUtils.escapeHtml(AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ID, &quot;(unknown node id!)&quot;)),</span>
<span class="nc" id="L308"> GetSubscriptionType(body),</span>
<span class="nc" id="L309"> GetChangeSummary(body));</span>
<span class="nc" id="L311"> content.setContent(msg_content, &quot;text/html; charset=UTF-8;&quot;);</span>
<span class="nc" id="L312"> mp.addBodyPart(content);</span>
<span class="nc" id="L314"> MimeBodyPart attachment = new MimeBodyPart();</span>
<span class="nc" id="L315"> attachment.setContent(subscriptionResultXML, &quot;text/xml; charset=UTF-8;&quot;);</span>
<span class="nc" id="L316"> attachment.setFileName(&quot;uddiNotification.xml&quot;);</span>
<span class="nc" id="L317"> mp.addBodyPart(attachment);</span>
<span class="nc" id="L319"> message.setContent(mp);</span>
<span class="nc" id="L320"> message.setSubject(ResourceConfig.getGlobalMessage(&quot;notifications.smtp.userfriendly.subject&quot;) + &quot; &quot;</span>
<span class="nc" id="L321"> + body.getSubscriptionResultsList().getSubscription().getSubscriptionKey());</span>
<span class="nc" id="L322"> Transport.send(message);</span>
<span class="nc" id="L323"> } else {</span>
<span class="nc" id="L324"> throw new DispositionReportFaultMessage(&quot;Session is null!&quot;, null);</span>
}
<span class="nc" id="L326"> } catch (Exception e) {</span>
<span class="nc" id="L327"> log.error(e.getMessage(), e);</span>
<span class="nc" id="L328"> throw new DispositionReportFaultMessage(e.getMessage(), null);</span>
<span class="nc" id="L329"> }</span>
<span class="nc" id="L331"> DispositionReport dr = new DispositionReport();</span>
<span class="nc" id="L332"> Result res = new Result();</span>
<span class="nc" id="L333"> dr.getResult().add(res);</span>
<span class="nc" id="L335"> return dr;</span>
}
static String GetChangeSummary(NotifySubscriptionListener body) {
<span class="nc" id="L339"> SubscriptionResultsList r = body.getSubscriptionResultsList();</span>
<span class="nc" id="L340"> StringWriter sw = new StringWriter();</span>
<span class="nc bnc" id="L342" title="All 2 branches missed."> if (r.getAssertionStatusReport() != null) {</span>
<span class="nc" id="L343"> JAXB.marshal(r.getAssertionStatusReport(), sw);</span>
<span class="nc bnc" id="L344" title="All 2 branches missed."> } else if (r.getBindingDetail() != null) {</span>
<span class="nc" id="L345"> JAXB.marshal(r.getBindingDetail(), sw);</span>
<span class="nc bnc" id="L346" title="All 2 branches missed."> } else if (r.getBusinessDetail() != null) {</span>
<span class="nc" id="L347"> JAXB.marshal(r.getBusinessDetail(), sw);</span>
<span class="nc bnc" id="L348" title="All 2 branches missed."> } else if (r.getBusinessList() != null) {</span>
<span class="nc" id="L349"> JAXB.marshal(r.getBusinessList(), sw);</span>
<span class="nc bnc" id="L350" title="All 2 branches missed."> } else if (r.getRelatedBusinessesList() != null) {</span>
<span class="nc" id="L351"> JAXB.marshal(r.getRelatedBusinessesList(), sw);</span>
<span class="nc bnc" id="L352" title="All 2 branches missed."> } else if (r.getServiceDetail() != null) {</span>
<span class="nc" id="L353"> JAXB.marshal(r.getServiceDetail(), sw);</span>
<span class="nc bnc" id="L354" title="All 2 branches missed."> } else if (r.getServiceList() != null) {</span>
<span class="nc" id="L355"> JAXB.marshal(r.getServiceList(), sw);</span>
<span class="nc bnc" id="L356" title="All 2 branches missed."> } else if (r.getTModelDetail() != null) {</span>
<span class="nc" id="L357"> JAXB.marshal(r.getTModelDetail(), sw);</span>
<span class="nc bnc" id="L358" title="All 2 branches missed."> } else if (r.getTModelList() != null) {</span>
<span class="nc" id="L359"> JAXB.marshal(r.getTModelList(), sw);</span>
}
<span class="nc" id="L362"> return &quot;&lt;pre&gt;&quot; + StringEscapeUtils.escapeHtml(sw.toString()) + &quot;&lt;/pre&gt;&quot;;</span>
}
static String GetSubscriptionType(NotifySubscriptionListener body) {
<span class="nc bnc" id="L366" title="All 4 branches missed."> if (body != null &amp;&amp; body.getSubscriptionResultsList() != null</span>
<span class="nc bnc" id="L367" title="All 2 branches missed."> &amp;&amp; body.getSubscriptionResultsList().getSubscription() != null</span>
<span class="nc bnc" id="L368" title="All 2 branches missed."> &amp;&amp; body.getSubscriptionResultsList().getSubscription().getSubscriptionFilter() != null) {</span>
<span class="nc" id="L369"> SubscriptionFilter sub = body.getSubscriptionResultsList().getSubscription().getSubscriptionFilter();</span>
<span class="nc bnc" id="L370" title="All 2 branches missed."> if (sub.getFindBinding() != null) {</span>
<span class="nc" id="L371"> return &quot; binding search results&quot;;</span>
}
<span class="nc bnc" id="L373" title="All 2 branches missed."> if (sub.getFindBusiness() != null) {</span>
<span class="nc" id="L374"> return &quot; business search results&quot;;</span>
}
<span class="nc bnc" id="L376" title="All 2 branches missed."> if (sub.getFindRelatedBusinesses() != null) {</span>
<span class="nc" id="L377"> return &quot; related business search results&quot;;</span>
}
<span class="nc bnc" id="L379" title="All 2 branches missed."> if (sub.getFindService() != null) {</span>
<span class="nc" id="L380"> return &quot; service search results&quot;;</span>
}
<span class="nc bnc" id="L382" title="All 2 branches missed."> if (sub.getFindTModel() != null) {</span>
<span class="nc" id="L383"> return &quot; tModel search results&quot;;</span>
}
<span class="nc bnc" id="L385" title="All 2 branches missed."> if (sub.getGetAssertionStatusReport() != null) {</span>
<span class="nc" id="L386"> return &quot; assertion status report&quot;;</span>
}
<span class="nc bnc" id="L388" title="All 2 branches missed."> if (sub.getGetBindingDetail() != null) {</span>
<span class="nc" id="L389"> return &quot; details on a specific binding&quot;;</span>
}
<span class="nc bnc" id="L391" title="All 2 branches missed."> if (sub.getGetBusinessDetail() != null) {</span>
<span class="nc" id="L392"> return &quot; details on a specific business&quot;;</span>
}
<span class="nc bnc" id="L394" title="All 2 branches missed."> if (sub.getGetServiceDetail() != null) {</span>
<span class="nc" id="L395"> return &quot; details on a specific service&quot;;</span>
}
<span class="nc bnc" id="L397" title="All 2 branches missed."> if (sub.getGetTModelDetail() != null) {</span>
<span class="nc" id="L398"> return &quot; details on a specific tModel&quot;;</span>
}
}
<span class="nc" id="L401"> return &quot; (unable to determine what the subscription type is)&quot;;</span>
}
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.7.9.201702052155</span></div></body></html>