You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2014/05/20 19:58:29 UTC

svn commit: r1596340 - in /airavata/sandbox/gfac-sample/local-handler-sample: build.xml pom.xml src/main/java/org/apache/airavata/gfac/local/handler/InputEmailHandler.java src/main/java/org/apache/airavata/gfac/local/handler/OutputEmailHandler.java

Author: lahiru
Date: Tue May 20 17:58:28 2014
New Revision: 1596340

URL: http://svn.apache.org/r1596340
Log:
fixing further issue

Modified:
    airavata/sandbox/gfac-sample/local-handler-sample/build.xml
    airavata/sandbox/gfac-sample/local-handler-sample/pom.xml
    airavata/sandbox/gfac-sample/local-handler-sample/src/main/java/org/apache/airavata/gfac/local/handler/InputEmailHandler.java
    airavata/sandbox/gfac-sample/local-handler-sample/src/main/java/org/apache/airavata/gfac/local/handler/OutputEmailHandler.java

Modified: airavata/sandbox/gfac-sample/local-handler-sample/build.xml
URL: http://svn.apache.org/viewvc/airavata/sandbox/gfac-sample/local-handler-sample/build.xml?rev=1596340&r1=1596339&r2=1596340&view=diff
==============================================================================
--- airavata/sandbox/gfac-sample/local-handler-sample/build.xml (original)
+++ airavata/sandbox/gfac-sample/local-handler-sample/build.xml Tue May 20 17:58:28 2014
@@ -13,7 +13,9 @@
     <path id="javac.classpath">
         <pathelement path="${build}"/>
         <fileset dir="${airavata.home}/lib">
-            <include name="airavata-gfac-core-0.12-SNAPSHOT.jar"/>
+            <include name="airavata-gfac-core-*.jar"/>
+            <include name="airavata-gfac-schema-utils-*.jar"/>
+            <include name="xmlbeans*.jar"/>
         </fileset>
         <fileset dir="src/main/resources">
             <include name="*.jar"/>

Modified: airavata/sandbox/gfac-sample/local-handler-sample/pom.xml
URL: http://svn.apache.org/viewvc/airavata/sandbox/gfac-sample/local-handler-sample/pom.xml?rev=1596340&r1=1596339&r2=1596340&view=diff
==============================================================================
--- airavata/sandbox/gfac-sample/local-handler-sample/pom.xml (original)
+++ airavata/sandbox/gfac-sample/local-handler-sample/pom.xml Tue May 20 17:58:28 2014
@@ -25,11 +25,6 @@
 
     <dependencies>
 
-        <!-- Logging -->
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-        </dependency>
 
         <!-- GFAC schemas -->
         <dependency>
@@ -37,30 +32,13 @@
             <artifactId>airavata-gfac-core</artifactId>
             <version>${project.version}</version>
         </dependency>
-
-        <!-- Test -->
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
-            <groupId>org.testng</groupId>
-            <artifactId>testng</artifactId>
-            <version>6.1.1</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>jcl-over-slf4j</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
+            <groupId>javax.mail</groupId>
+            <artifactId>mail</artifactId>
+            <version>1.4.5</version>
         </dependency>
 
+
     </dependencies>
 
 </project>

Modified: airavata/sandbox/gfac-sample/local-handler-sample/src/main/java/org/apache/airavata/gfac/local/handler/InputEmailHandler.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gfac-sample/local-handler-sample/src/main/java/org/apache/airavata/gfac/local/handler/InputEmailHandler.java?rev=1596340&r1=1596339&r2=1596340&view=diff
==============================================================================
--- airavata/sandbox/gfac-sample/local-handler-sample/src/main/java/org/apache/airavata/gfac/local/handler/InputEmailHandler.java (original)
+++ airavata/sandbox/gfac-sample/local-handler-sample/src/main/java/org/apache/airavata/gfac/local/handler/InputEmailHandler.java Tue May 20 17:58:28 2014
@@ -20,24 +20,84 @@
 */
 package org.apache.airavata.gfac.local.handler;
 
+import org.apache.airavata.commons.gfac.type.ActualParameter;
 import org.apache.airavata.gfac.core.context.JobExecutionContext;
 import org.apache.airavata.gfac.core.handler.GFacHandler;
 import org.apache.airavata.gfac.core.handler.GFacHandlerException;
-import javax.mail.*;
+import org.apache.airavata.schemas.gfac.StringParameterType;
+
 import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
 import java.lang.String;
 import java.util.Map;
 import java.util.Properties;
 
+
+
 public class InputEmailHandler implements GFacHandler {
     private Properties props;
 
     public void initProperties(Properties properties) throws GFacHandlerException {
+        System.out.println("Initializing " + InputEmailHandler.class + " Handler...");
         props = properties;
     }
 
     public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
+//        Session session = Session.getInstance(props,
+//                new javax.mail.Authenticator() {
+//                    protected PasswordAuthentication getPasswordAuthentication() {
+//                        return new PasswordAuthentication((String) props.get("username"), (String) props.get("password"));
+//                    }
+//                });
+//
+//        Message message = new MimeMessage(session);
+//        try {
+//            message.setFrom(new InternetAddress((String) props.get("username")));
+//            message.setRecipients(Message.RecipientType.TO,
+//                    InternetAddress.parse((String) props.get("username")));
+//            message.setSubject("GFAC Input Email");
+//
+
+//            Transport.send(message);
+//        } catch (MessagingException e) {
+//            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+//        }
+//        System.out.println("Start Emailing the input values ... ");
+//        try {
+//            Session mailSession = Session.getDefaultInstance(props, null);
+//            Transport transport = mailSession.getTransport();
+//
+//            MimeMessage message = new MimeMessage(mailSession);
+//            message.setSubject("GFAC Inputs");
+//            Map<String, Object> parameters = jobExecutionContext.getOutMessageContext().getParameters();
+//            StringBuffer buffer = new StringBuffer();
+//            for (String input : parameters.keySet()) {
+//                ActualParameter inParam = (ActualParameter) parameters.get(input);
+//                String paramDataType = inParam.getType().getType().toString();
+//                if ("String".equals(paramDataType)) {
+//                    String stringPrm = ((StringParameterType) inParam.getType())
+//                            .getValue();
+//                    buffer.append("Input Name: input: Input Value: " + stringPrm + "\n");
+//                }
+//            }
+//            message.setContent(buffer.toString(), "text/plain");
+//            message.addRecipient(Message.RecipientType.TO,
+//                    new InternetAddress((String) props.get("username")));
+//
+//            transport.connect();
+//            transport.sendMessage(message,
+//                    message.getRecipients(Message.RecipientType.TO));
+//            transport.close();
+//            System.out.println("Sent email to : " + props.get("username"));
+//        } catch (Exception e) {
+//
+//        }
+             System.out.println("Start Emailing the input values ... ");
         Session session = Session.getInstance(props,
                 new javax.mail.Authenticator() {
                     protected PasswordAuthentication getPasswordAuthentication() {
@@ -55,9 +115,17 @@ public class InputEmailHandler implement
             Map<String, Object> parameters = jobExecutionContext.getInMessageContext().getParameters();
             StringBuffer buffer = new StringBuffer();
             for (String input : parameters.keySet()) {
-                buffer.append("Input Name: input: Input Value: " + parameters.get(input) + "\n");
+                ActualParameter inParam = (ActualParameter) parameters.get(input);
+                String paramDataType = inParam.getType().getType().toString();
+                if ("String".equals(paramDataType)) {
+                    String stringPrm = ((StringParameterType) inParam.getType())
+                            .getValue();
+                    buffer.append("Input Name: input: Input Value: " + stringPrm + "\n");
+                }
             }
+            message.setText(buffer.toString());
             Transport.send(message);
+            System.out.println("Sent email to : " + props.get("username"));
         } catch (MessagingException e) {
             e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
         }

Modified: airavata/sandbox/gfac-sample/local-handler-sample/src/main/java/org/apache/airavata/gfac/local/handler/OutputEmailHandler.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gfac-sample/local-handler-sample/src/main/java/org/apache/airavata/gfac/local/handler/OutputEmailHandler.java?rev=1596340&r1=1596339&r2=1596340&view=diff
==============================================================================
--- airavata/sandbox/gfac-sample/local-handler-sample/src/main/java/org/apache/airavata/gfac/local/handler/OutputEmailHandler.java (original)
+++ airavata/sandbox/gfac-sample/local-handler-sample/src/main/java/org/apache/airavata/gfac/local/handler/OutputEmailHandler.java Tue May 20 17:58:28 2014
@@ -20,9 +20,11 @@
 */
 package org.apache.airavata.gfac.local.handler;
 
+import org.apache.airavata.commons.gfac.type.ActualParameter;
 import org.apache.airavata.gfac.core.context.JobExecutionContext;
 import org.apache.airavata.gfac.core.handler.GFacHandler;
 import org.apache.airavata.gfac.core.handler.GFacHandlerException;
+import org.apache.airavata.schemas.gfac.StringParameterType;
 
 import javax.mail.*;
 import javax.mail.internet.InternetAddress;
@@ -34,10 +36,12 @@ public class OutputEmailHandler implemen
     private Properties props;
 
     public void initProperties(Properties properties) throws GFacHandlerException {
+        System.out.println("Initializing " + OutputEmailHandler.class + " Handler...");
         props = properties;
     }
 
     public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
+        System.out.println("Start Emailing the output values ... ");
         Session session = Session.getInstance(props,
                 new javax.mail.Authenticator() {
                     protected PasswordAuthentication getPasswordAuthentication() {
@@ -50,15 +54,22 @@ public class OutputEmailHandler implemen
             message.setFrom(new InternetAddress((String) props.get("username")));
             message.setRecipients(Message.RecipientType.TO,
                     InternetAddress.parse((String) props.get("username")));
-            message.setSubject("GFAC Input Email");
+            message.setSubject("GFAC Output Email");
 
             Map<String, Object> parameters = jobExecutionContext.getOutMessageContext().getParameters();
             StringBuffer buffer = new StringBuffer();
             for (String input : parameters.keySet()) {
-                buffer.append("Input Name: input: Input Value: " + parameters.get(input) + "\n");
+                ActualParameter inParam = (ActualParameter) parameters.get(input);
+                String paramDataType = inParam.getType().getType().toString();
+                if ("String".equals(paramDataType)) {
+                    String stringPrm = ((StringParameterType) inParam.getType())
+                            .getValue();
+                    buffer.append("Output Name: " + input + " Output Value: " + stringPrm + "\n");
+                }
             }
             message.setText(buffer.toString());
             Transport.send(message);
+            System.out.println("Sent email to : " + props.get("username"));
         } catch (MessagingException e) {
             e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
         }