Author: bfoster
Date: Sat Mar 3 01:49:55 2012
New Revision: 1296550
URL: http://svn.apache.org/viewvc?rev=1296550&view=rev
Log:
- Added options for CAS-Crawler's SendNotification CrawlerAction
---------------
OODT-400
Modified:
oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/EmailNotification.java
oodt/trunk/crawler/src/main/resources/cmd-line-options.xml
Modified:
oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/EmailNotification.java
URL:
http://svn.apache.org/viewvc/oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/EmailNotification.java?rev=1296550&r1=1296549&r2=1296550&view=diff
==============================================================================
---
oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/EmailNotification.java
(original)
+++
oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/EmailNotification.java
Sat Mar 3 01:49:55 2012
@@ -18,6 +18,7 @@ package org.apache.oodt.cas.crawl.action
//JDK imports
import java.io.File;
+import java.util.List;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.Session;
@@ -38,6 +39,8 @@ import org.apache.oodt.cas.crawl.structs
import org.apache.oodt.cas.metadata.Metadata;
import org.apache.oodt.cas.metadata.util.PathUtils;
+import com.google.common.collect.Lists;
+
/**
* This action sends an email notification. It performs metadata and system
* property replacement on the subject, recipients, and message. This allows
the
@@ -52,7 +55,7 @@ public class EmailNotification extends C
private String mailHost;
private String subject;
private String message;
- private String recipients;
+ private List<String> recipients;
private String sender;
private boolean ignoreInvalidAddresses;
@@ -74,8 +77,7 @@ public class EmailNotification extends C
msg.setSubject(PathUtils.doDynamicReplacement(subject, metadata));
msg.setText(new String(PathUtils.doDynamicReplacement(message,
metadata).getBytes()));
- String[] recips = recipients.split(",");
- for (String recipient : recips) {
+ for (String recipient : recipients) {
try {
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(
PathUtils.replaceEnvVariables(recipient.trim(), metadata),
@@ -129,8 +131,13 @@ public class EmailNotification extends C
this.message = message;
}
- @Required
public void setRecipients(String recipients) {
+ if (recipients != null) {
+ this.recipients = Lists.newArrayList(recipients.split(","));
+ }
+ }
+
+ public void setRecipients(List<String> recipients) {
this.recipients = recipients;
}
Modified: oodt/trunk/crawler/src/main/resources/cmd-line-options.xml
URL:
http://svn.apache.org/viewvc/oodt/trunk/crawler/src/main/resources/cmd-line-options.xml?rev=1296550&r1=1296549&r2=1296550&view=diff
==============================================================================
--- oodt/trunk/crawler/src/main/resources/cmd-line-options.xml (original)
+++ oodt/trunk/crawler/src/main/resources/cmd-line-options.xml Sat Mar 3
01:49:55 2012
@@ -725,4 +725,143 @@
</bean>
</property>
</bean>
+
+ <bean id="notification"
class="org.apache.oodt.cas.cli.option.GroupCmdLineOption">
+ <property name="shortOption" value="n" />
+ <property name="longOption" value="notification" />
+ <property name="description" value="Declare that your want email
notification" />
+ <property name="hasArgs" value="false" />
+ <property name="required" value="false" />
+ <property name="subOptions">
+ <list>
+ <bean class="org.apache.oodt.cas.cli.option.GroupSubOption"
+ p:option-ref="mailHost" p:required="true" />
+ <bean class="org.apache.oodt.cas.cli.option.GroupSubOption"
+ p:option-ref="sender" p:required="true" />
+ <bean class="org.apache.oodt.cas.cli.option.GroupSubOption"
+ p:option-ref="subject" p:required="true" />
+ <bean class="org.apache.oodt.cas.cli.option.GroupSubOption"
+ p:option-ref="message" p:required="true" />
+ <bean class="org.apache.oodt.cas.cli.option.GroupSubOption"
+ p:option-ref="recipients" p:required="true" />
+ <bean class="org.apache.oodt.cas.cli.option.GroupSubOption"
+ p:option-ref="ignoreInvalidAddresses" p:required="false" />
+ </list>
+ </property>
+ </bean>
+
+ <bean id="mailHost"
class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"
+ p:isSubOption="true">
+ <property name="shortOption" value="mh" />
+ <property name="longOption" value="mailHost" />
+ <property name="description" value="Email Host" />
+ <property name="hasArgs" value="true" />
+ <property name="argsDescription" value="host" />
+ <property name="required" value="false" />
+ <property name="handler">
+ <bean
class="org.apache.oodt.cas.crawl.cli.option.handler.CrawlerBeansPropHandler">
+ <property name="properties">
+ <list>
+ <value>SendNotification.emailHost</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+
+ <bean id="sender"
class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"
+ p:isSubOption="true">
+ <property name="shortOption" value="sdr" />
+ <property name="longOption" value="sender" />
+ <property name="description" value="Email sender" />
+ <property name="hasArgs" value="true" />
+ <property name="argsDescription" value="email address" />
+ <property name="required" value="false" />
+ <property name="handler">
+ <bean
class="org.apache.oodt.cas.crawl.cli.option.handler.CrawlerBeansPropHandler">
+ <property name="properties">
+ <list>
+ <value>SendNotification.sender</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+
+ <bean id="subject"
class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"
+ p:isSubOption="true">
+ <property name="shortOption" value="sub" />
+ <property name="longOption" value="subject" />
+ <property name="description" value="Email subject" />
+ <property name="hasArgs" value="true" />
+ <property name="argsDescription" value="email subject" />
+ <property name="required" value="false" />
+ <property name="handler">
+ <bean
class="org.apache.oodt.cas.crawl.cli.option.handler.CrawlerBeansPropHandler">
+ <property name="properties">
+ <list>
+ <value>SendNotification.subject</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+
+ <bean id="message"
class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"
+ p:isSubOption="true">
+ <property name="shortOption" value="msg" />
+ <property name="longOption" value="message" />
+ <property name="description" value="Email message body" />
+ <property name="hasArgs" value="true" />
+ <property name="argsDescription" value="email message" />
+ <property name="required" value="false" />
+ <property name="handler">
+ <bean
class="org.apache.oodt.cas.crawl.cli.option.handler.CrawlerBeansPropHandler">
+ <property name="properties">
+ <list>
+ <value>SendNotification.message</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+
+ <bean id="recipients"
class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"
+ p:isSubOption="true">
+ <property name="shortOption" value="rcpts" />
+ <property name="longOption" value="recipients" />
+ <property name="description" value="List of recipient emails" />
+ <property name="type" value="java.util.List" />
+ <property name="hasArgs" value="true" />
+ <property name="argsDescription" value="email addresses" />
+ <property name="required" value="false" />
+ <property name="handler">
+ <bean
class="org.apache.oodt.cas.crawl.cli.option.handler.CrawlerBeansPropHandler">
+ <property name="properties">
+ <list>
+ <value>SendNotification.recipients</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+
+ <bean id="ignoreInvalidAddresses"
class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"
+ p:isSubOption="true">
+ <property name="shortOption" value="iias" />
+ <property name="longOption" value="ignoreInvalidAddresses" />
+ <property name="description" value="If invalid addresses should just be
ignored" />
+ <property name="type" value="boolean" />
+ <property name="hasArgs" value="false" />
+ <property name="required" value="false" />
+ <property name="handler">
+ <bean
class="org.apache.oodt.cas.crawl.cli.option.handler.CrawlerBeansPropHandler">
+ <property name="properties">
+ <list>
+ <value>SendNotification.ignoreInvalidAddresses</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
</beans>