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 2013/03/29 17:59:37 UTC

svn commit: r1462532 - in /airavata/sandbox/handlerTutotial: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/airavata/ src/main/java/org/apache/airavata/gfac/ src/main/java/org/apache/airavata/gfac...

Author: lahiru
Date: Fri Mar 29 16:59:37 2013
New Revision: 1462532

URL: http://svn.apache.org/r1462532
Log:
addng handler tutorial content.

Added:
    airavata/sandbox/handlerTutotial/pom.xml
    airavata/sandbox/handlerTutotial/src/
    airavata/sandbox/handlerTutotial/src/main/
    airavata/sandbox/handlerTutotial/src/main/java/
    airavata/sandbox/handlerTutotial/src/main/java/org/
    airavata/sandbox/handlerTutotial/src/main/java/org/apache/
    airavata/sandbox/handlerTutotial/src/main/java/org/apache/airavata/
    airavata/sandbox/handlerTutotial/src/main/java/org/apache/airavata/gfac/
    airavata/sandbox/handlerTutotial/src/main/java/org/apache/airavata/gfac/handler/
    airavata/sandbox/handlerTutotial/src/main/java/org/apache/airavata/gfac/handler/OutputEmailHandler.java
    airavata/sandbox/handlerTutotial/src/main/resources/
    airavata/sandbox/handlerTutotial/src/main/resources/service.properties

Added: airavata/sandbox/handlerTutotial/pom.xml
URL: http://svn.apache.org/viewvc/airavata/sandbox/handlerTutotial/pom.xml?rev=1462532&view=auto
==============================================================================
--- airavata/sandbox/handlerTutotial/pom.xml (added)
+++ airavata/sandbox/handlerTutotial/pom.xml Fri Mar 29 16:59:37 2013
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--Licensed to the Apache Software Foundation (ASF) under one or more contributor 
+	license agreements. See the NOTICE file distributed with this work for additional 
+	information regarding copyright ownership. The ASF licenses this file to 
+	you under the Apache License, Version 2.0 (theÏ "License"); 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 "AS IS" 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. -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<groupId>org.apache.airavata</groupId>
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>airavata-gfac-handler</artifactId>
+	<version>0.7-SNAPSHOT</version>
+	<name>Airavata GFac Handler Sample</name>
+	<description>The core GFAC functionality independent from any webservice implementation.</description>
+	<url>http://airavata.apache.org/</url>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.airavata</groupId>
+			<artifactId>airavata-gfac-core</artifactId>
+			<version>0.7-SNAPSHOT</version>
+		</dependency>
+              
+     
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-surefire-plugin</artifactId>
+				<configuration>
+					<!--skip>true</skip -->
+					<excludes>
+						<exclude>**/services/**</exclude>
+					</excludes>
+					<forkMode>always</forkMode>
+					<useSystemClassloader>true</useSystemClassloader>
+					<failIfNoTests>false</failIfNoTests>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
+</project>

Added: airavata/sandbox/handlerTutotial/src/main/java/org/apache/airavata/gfac/handler/OutputEmailHandler.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/handlerTutotial/src/main/java/org/apache/airavata/gfac/handler/OutputEmailHandler.java?rev=1462532&view=auto
==============================================================================
--- airavata/sandbox/handlerTutotial/src/main/java/org/apache/airavata/gfac/handler/OutputEmailHandler.java (added)
+++ airavata/sandbox/handlerTutotial/src/main/java/org/apache/airavata/gfac/handler/OutputEmailHandler.java Fri Mar 29 16:59:37 2013
@@ -0,0 +1,91 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); 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
+ * "AS IS" 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.airavata.gfac.handler;
+
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.commons.gfac.type.MappingFactory;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+public class OutputEmailHandler implements GFacHandler {
+    public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException, GFacException {
+        String emailContent = "";
+        Map<String, Object> parameters = jobExecutionContext.getOutMessageContext().getParameters();
+        Set<String> keys = parameters.keySet();
+        for (String key : keys) {
+            ActualParameter output = (ActualParameter) parameters.get(key);
+            String s = MappingFactory.toString(output);
+            emailContent = emailContent + "\n" + key + ":" + s;
+        }
+        try {
+            sendEmail(emailContent);
+        } catch (MessagingException e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+    }
+
+    private void sendEmail(String mailContent) throws MessagingException {
+        String host = "smtp.gmail.com";
+    String from = "airavatamail";
+    String pass = "apachetlp";
+    Properties props = System.getProperties();
+    props.put("mail.smtp.starttls.enable", "true"); // added this line
+    props.put("mail.smtp.host", host);
+    props.put("mail.smtp.user", from);
+    props.put("mail.smtp.password", pass);
+    props.put("mail.smtp.port", "587");
+    props.put("mail.smtp.auth", "true");
+
+    String[] to = {"glahiru@gmail.com"}; // added this line
+
+    Session session = Session.getDefaultInstance(props, null);
+    MimeMessage message = new MimeMessage(session);
+    message.setFrom(new InternetAddress(from));
+
+    InternetAddress[] toAddress = new InternetAddress[to.length];
+
+    // To get the array of addresses
+    for( int i=0; i < to.length; i++ ) { // changed from a while loop
+        toAddress[i] = new InternetAddress(to[i]);
+    }
+
+    for( int i=0; i < toAddress.length; i++) { // changed from a while loop
+        message.addRecipient(Message.RecipientType.TO, toAddress[i]);
+    }
+    message.setSubject("WorkflowOutputs");
+    message.setText(mailContent);
+    Transport transport = session.getTransport("smtp");
+    transport.connect(host, from, pass);
+    transport.sendMessage(message, message.getAllRecipients());
+    transport.close();
+    }
+}
+

Added: airavata/sandbox/handlerTutotial/src/main/resources/service.properties
URL: http://svn.apache.org/viewvc/airavata/sandbox/handlerTutotial/src/main/resources/service.properties?rev=1462532&view=auto
==============================================================================
--- airavata/sandbox/handlerTutotial/src/main/resources/service.properties (added)
+++ airavata/sandbox/handlerTutotial/src/main/resources/service.properties Fri Mar 29 16:59:37 2013
@@ -0,0 +1,67 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); 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
+# "AS IS" 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.
+#
+#
+
+#
+# Properties for JCR Registry interface. By default, Apache Jackrabbit is used.
+#
+# org.apache.jackrabbit.repository.uri=http://localhost:8080/rmi
+# jcr.class=org.apache.jackrabbit.rmi.repository.RmiRepositoryFactory
+jcr.class=org.apache.jackrabbit.core.RepositoryFactoryImpl
+jcr.user=admin
+jcr.pass=admin
+
+
+#
+# Class which implemented Scheduler interface. It will be used to determine a Provider
+#
+scheduler.class= org.apache.airavata.core.gfac.scheduler.impl.SchedulerImpl
+
+#
+# Data Service Plugins classes
+#
+datachain.classes= org.apache.airavata.core.gfac.extension.data.RegistryDataService
+
+#
+# Pre execution Plugins classes. For example, GridFTP Input Staging
+#
+prechain.classes= org.apache.airavata.core.gfac.extension.pre.GridFtpInputStaging 
+prechain.classes= org.apache.airavata.core.gfac.extension.pre.HttpInputStaging
+
+#
+# Post execution Plugins classes. For example, GridFTP Output Staging
+#
+postchain.classes= org.apache.airavata.core.gfac.extension.post.GridFtpOutputStaging
+postchain.classes= org.apache.airavata.core.gfac.extension.post.OutputRegister
+
+#
+# SSH private key location. It will be used by SSHProvider
+#
+# ssh.key=/home/user/.ssh/id_rsa
+# ssh.keypass=
+# ssh.username=usernameAtHost
+
+#
+# MyProxy credential. It will be used by GridFTP Plugins and GramProvider.
+#
+# myproxy.server=myproxy.teragrid.org
+# myproxy.user=username
+# myproxy.pass=password
+# myproxy.life=3600
\ No newline at end of file