juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexo...@apache.org
Subject git commit: JUDDI-773 done JUDDI-857 fixed
Date Thu, 20 Feb 2014 12:32:26 GMT
Repository: juddi
Updated Branches:
  refs/heads/master 1ac9e9d65 -> bff4c5638


JUDDI-773 done
JUDDI-857 fixed


Project: http://git-wip-us.apache.org/repos/asf/juddi/repo
Commit: http://git-wip-us.apache.org/repos/asf/juddi/commit/bff4c563
Tree: http://git-wip-us.apache.org/repos/asf/juddi/tree/bff4c563
Diff: http://git-wip-us.apache.org/repos/asf/juddi/diff/bff4c563

Branch: refs/heads/master
Commit: bff4c56389d3f8ca988261ceb634c5d11dceb66a
Parents: 1ac9e9d
Author: alex <spyhunter99@gmail.com>
Authored: Thu Feb 20 07:32:01 2014 -0500
Committer: alex <spyhunter99@gmail.com>
Committed: Thu Feb 20 07:32:01 2014 -0500

----------------------------------------------------------------------
 .../juddi/subscription/notify/SMTPNotifier.java |   3 +-
 .../notify/USERFRIENDLYSMTPNotifier.java        | 191 +++++++++++++++++++
 .../apache/juddi/webconsole/hub/UddiHub.java    |   4 +
 juddi-gui/src/main/webapp/editSubscription.jsp  |   2 +-
 .../src/main/webapp/quickref_tmodelinstance.jsp |   1 +
 5 files changed, 199 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/juddi/blob/bff4c563/juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java
b/juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java
index af83934..b0c684c 100644
--- a/juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java
+++ b/juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java
@@ -24,6 +24,7 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.juddi.api_v3.AccessPointType;
 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.model.BindingTemplate;
@@ -142,7 +143,7 @@ public class SMTPNotifier implements Notifier {
 				String subscriptionResultXML = JAXBMarshaller.marshallToString(body, JAXBMarshaller.PACKAGE_SUBSCR_RES);
 				message.setText(subscriptionResultXML, "UTF-8");
                                 //message.setContent(subscriptionResultXML, "text/xml; charset=UTF-8;");
-				message.setSubject("UDDI Subscription Notification for subscription " 
+				message.setSubject(ResourceConfig.getGlobalMessage("notifications.smtp.default.subject")
+ " " 
 						+ body.getSubscriptionResultsList().getSubscription().getSubscriptionKey());
 				Transport.send(message);
 			}

http://git-wip-us.apache.org/repos/asf/juddi/blob/bff4c563/juddi-core/src/main/java/org/apache/juddi/subscription/notify/USERFRIENDLYSMTPNotifier.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/java/org/apache/juddi/subscription/notify/USERFRIENDLYSMTPNotifier.java
b/juddi-core/src/main/java/org/apache/juddi/subscription/notify/USERFRIENDLYSMTPNotifier.java
new file mode 100644
index 0000000..d0d7bd2
--- /dev/null
+++ b/juddi-core/src/main/java/org/apache/juddi/subscription/notify/USERFRIENDLYSMTPNotifier.java
@@ -0,0 +1,191 @@
+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.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.configuration.ConfigurationException;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.api_v3.AccessPointType;
+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.model.BindingTemplate;
+import org.apache.juddi.v3.error.ErrorMessage;
+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.
+ *
+ * "mail.smtp.from", "mail.smtp.host", "mail.smtp.port",
+ * "mail.smtp.socketFactory.class", "mail.smtp.socketFactory.fallback",
+ * "mail.smtp.starttls.enable",
+ * "mail.smtp.socketFactory.port","mail.smtp.auth","mail.smtp.user","mail.smtp.password"
+ *
+ * The following properties can be set juddiv3.xml.
+ *
+ * @author Kurt Stam
+ */
+public class USERFRIENDLYSMTPNotifier extends SMTPNotifier {
+
+        public USERFRIENDLYSMTPNotifier(BindingTemplate bindingTemplate) throws URISyntaxException,
Exception {
+                super(bindingTemplate);
+                publisherName = bindingTemplate.getAuthorizedName();
+        }
+
+        String publisherName;
+
+        @Override
+        public DispositionReport notifySubscriptionListener(NotifySubscriptionListener body)
throws DispositionReportFaultMessage, RemoteException {
+
+                try {
+                        log.info("Sending notification email to " + notificationEmailAddress
+ " from " + getEMailProperties().getProperty("mail.smtp.from", "jUDDI"));
+                        if (session != null && notificationEmailAddress != null)
{
+                                MimeMessage message = new MimeMessage(session);
+                                InternetAddress address = new InternetAddress(notificationEmailAddress);
+                                Address[] to = {address};
+                                message.setRecipients(RecipientType.TO, to);
+                                message.setFrom(new InternetAddress(getEMailProperties().getProperty("mail.smtp.from",
"jUDDI")));
+                                //maybe nice to use a template rather then sending raw xml.
+                                String subscriptionResultXML = JAXBMarshaller.marshallToString(body,
JAXBMarshaller.PACKAGE_SUBSCR_RES);
+                                Multipart mp = new MimeMultipart();
+                                
+                                MimeBodyPart content = new MimeBodyPart();
+                                String msg_content = ResourceConfig.getGlobalMessage("notifications.smtp.userfriendly.body");
+
+                                msg_content = String.format(msg_content,
+                                     StringEscapeUtils.escapeHtml(this.publisherName),
+                                     StringEscapeUtils.escapeHtml(AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ID,
"(unknown node id!)")),
+                                     GetSubscriptionType(body),
+                                     GetChangeSummary(body));
+                                
+                                content.setContent(msg_content, "text/html; charset=UTF-8;");
+                                mp.addBodyPart(content);
+                                
+                                MimeBodyPart attachment = new MimeBodyPart();
+                                attachment.setContent(subscriptionResultXML, "text/xml; charset=UTF-8;");
+                                attachment.setFileName("uddiNotification.xml");
+                                mp.addBodyPart(attachment);
+                                
+                                message.setContent(mp);
+                                message.setSubject(ResourceConfig.getGlobalMessage("notifications.smtp.userfriendly.subject")
+ " "
+                                     + body.getSubscriptionResultsList().getSubscription().getSubscriptionKey());
+                                Transport.send(message);
+                        }
+                } catch (Exception e) {
+                        log.error(e.getMessage(), e);
+                        throw new DispositionReportFaultMessage(e.getMessage(), null);
+                }
+
+                DispositionReport dr = new DispositionReport();
+                Result res = new Result();
+                dr.getResult().add(res);
+
+                return dr;
+        }
+
+        static String GetChangeSummary(NotifySubscriptionListener body) {
+                SubscriptionResultsList r = body.getSubscriptionResultsList();
+                StringWriter sw = new StringWriter();
+                
+                if (r.getAssertionStatusReport() != null) {
+                        JAXB.marshal(r.getAssertionStatusReport(), sw);
+                }
+                else if (r.getBindingDetail() != null) {
+                        JAXB.marshal(r.getBindingDetail(), sw);
+                }
+                else if (r.getBusinessDetail() != null) {
+                        JAXB.marshal(r.getBusinessDetail(), sw);
+                }
+                else if (r.getBusinessList() != null) {
+                        JAXB.marshal(r.getBusinessList(), sw);
+                }
+                else if (r.getRelatedBusinessesList() != null) {
+                        JAXB.marshal(r.getRelatedBusinessesList(), sw);
+                }
+                else if (r.getServiceDetail() != null) {
+                        JAXB.marshal(r.getServiceDetail(), sw);
+                }
+                else if (r.getServiceList() != null) {
+                        JAXB.marshal(r.getServiceList(), sw);
+                }
+                else if (r.getTModelDetail() != null) {
+                        JAXB.marshal(r.getTModelDetail(), sw);
+                }
+                else if (r.getTModelList() != null) {
+                        JAXB.marshal(r.getTModelList(), sw);
+                }
+                
+                return "<pre>" +StringEscapeUtils.escapeHtml(sw.toString()) + "</pre>";
+        }
+
+        static String GetSubscriptionType(NotifySubscriptionListener body) {
+                if (body != null && body.getSubscriptionResultsList() != null
+                     && body.getSubscriptionResultsList().getSubscription() != null
+                     && body.getSubscriptionResultsList().getSubscription().getSubscriptionFilter()
!= null) {
+                        SubscriptionFilter sub = body.getSubscriptionResultsList().getSubscription().getSubscriptionFilter();
+                        if (sub.getFindBinding() != null) {
+                                return " binding search results";
+                        }
+                        if (sub.getFindBusiness() != null) {
+                                return " business search results";
+                        }
+                        if (sub.getFindRelatedBusinesses() != null) {
+                                return " related business search results";
+                        }
+                        if (sub.getFindService() != null) {
+                                return " service search results";
+                        }
+                        if (sub.getFindTModel() != null) {
+                                return " tModel search results";
+                        }
+                        if (sub.getGetAssertionStatusReport() != null) {
+                                return " assertion status report";
+                        }
+                        if (sub.getGetBindingDetail() != null) {
+                                return " details on a specific binding";
+                        }
+                        if (sub.getGetBusinessDetail() != null) {
+                                return " details on a specific business";
+                        }
+                        if (sub.getGetServiceDetail() != null) {
+                                return " details on a specific service";
+                        }
+                        if (sub.getGetTModelDetail() != null) {
+                                return " details on a specific tModel";
+                        }
+                }
+                return " (unable to determine what the subscription type is)";
+
+        }
+
+}

http://git-wip-us.apache.org/repos/asf/juddi/blob/bff4c563/juddi-gui/src/main/java/org/apache/juddi/webconsole/hub/UddiHub.java
----------------------------------------------------------------------
diff --git a/juddi-gui/src/main/java/org/apache/juddi/webconsole/hub/UddiHub.java b/juddi-gui/src/main/java/org/apache/juddi/webconsole/hub/UddiHub.java
index 60f5cd2..e91e5d0 100644
--- a/juddi-gui/src/main/java/org/apache/juddi/webconsole/hub/UddiHub.java
+++ b/juddi-gui/src/main/java/org/apache/juddi/webconsole/hub/UddiHub.java
@@ -900,6 +900,8 @@ public class UddiHub implements Serializable {
                         return null;
                 }
 
+                if (serviceid.equalsIgnoreCase(ResourceLoader.GetResource(session, "items.clicktoedit")))
+                        return null;
                 try {
                         GetServiceDetail gbd = new GetServiceDetail();
                         gbd.setAuthInfo(GetToken());
@@ -1124,6 +1126,8 @@ public class UddiHub implements Serializable {
                 if (bizid == null || bizid.isEmpty()) {
                         return null;
                 }
+                if (bizid.equalsIgnoreCase(ResourceLoader.GetResource(session, "items.clicktoedit")))
+                        return null;
 
                 try {
                         GetBusinessDetail gbd = new GetBusinessDetail();

http://git-wip-us.apache.org/repos/asf/juddi/blob/bff4c563/juddi-gui/src/main/webapp/editSubscription.jsp
----------------------------------------------------------------------
diff --git a/juddi-gui/src/main/webapp/editSubscription.jsp b/juddi-gui/src/main/webapp/editSubscription.jsp
index 6e55511..cf85d4f 100644
--- a/juddi-gui/src/main/webapp/editSubscription.jsp
+++ b/juddi-gui/src/main/webapp/editSubscription.jsp
@@ -238,7 +238,7 @@
                             <div class="<%=((sub.getBindingKey() != null &&
sub.getBindingKey().trim().length()>0) ? "" : " hide ")%>" id="bindingKeyDiv">
                                 <%=ResourceLoader.GetResource(session, "pages.subscription.step3.content")%>
                                 <b><%=UDDIConstants.TRANSPORT_HTTP%></b>.
-                                <input type="text" id="bindingKey" placeholder="<%=ResourceLoader.GetResource(session,
"items.bindingtemplate.key")%>" style="width:360px">
+                                <input type="text" id="bindingKey" placeholder="<%=ResourceLoader.GetResource(session,
"items.bindingtemplate.key")%>" style="width:360px" value="<%=(sub.getBindingKey() !=
null ? StringEscapeUtils.escapeHtml(sub.getBindingKey()):"")%>">
                                 <button onClick="javascript:bindingModal('bindingKey',
'val');
                                         return false;" class="btn "><%=ResourceLoader.GetResource(session,
"actions.select")%></button>
                             </div>

http://git-wip-us.apache.org/repos/asf/juddi/blob/bff4c563/juddi-gui/src/main/webapp/quickref_tmodelinstance.jsp
----------------------------------------------------------------------
diff --git a/juddi-gui/src/main/webapp/quickref_tmodelinstance.jsp b/juddi-gui/src/main/webapp/quickref_tmodelinstance.jsp
index 6ebbcab..df96c85 100644
--- a/juddi-gui/src/main/webapp/quickref_tmodelinstance.jsp
+++ b/juddi-gui/src/main/webapp/quickref_tmodelinstance.jsp
@@ -24,6 +24,7 @@
                 <li><a href="javascript:AddTmodelInstanceParam('uddi:uddi.org:transport:jms');">JMS</a></li>
                 <li><a href="javascript:AddTmodelInstanceParam('uddi:uddi.org:transport:ftp');">FTP</a></li>
                 <li><a href="javascript:AddTmodelInstanceParam('uddi:uddi.org:transport:smtp');">SMTP</a></li>
+                <li><a href="javascript:AddTmodelInstanceParam('uddi:uddi.org:transport:userfriendlysmtp');">User
Friendly SMTP</a></li>
                 <li><a href="javascript:AddTmodelInstanceParam('uddi:uddi.org:transport:jndi-rmi');">JNDI-RMI</a></li>
                 <li><a href="javascript:AddTmodelInstanceParam('uddi:uddi.org:transport:rmi');">RMI</a></li>
                 <li><a href="javascript:AddTmodelInstanceParam('uddi:uddi.org:transport:omgdds');">OMG
DDS</a></li>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org


Mime
View raw message