[MOBY-guts] biomoby commit

Eddie Kawas kawas at pub.open-bio.org
Thu Nov 10 16:09:57 UTC 2005


kawas
Thu Nov 10 11:09:56 EST 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util
In directory pub.open-bio.org:/tmp/cvs-serv5735/org/biomoby/registry/rdfagent/util

Modified Files:
	Report.java 
Log Message:
added a clear method that erases the old report

moby-live/Java/src/main/org/biomoby/registry/rdfagent/util Report.java,1.8,1.9
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java	2005/09/29 20:14:11	1.8
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java	2005/11/10 16:09:56	1.9
@@ -26,9 +26,9 @@
 
 public class Report {
 
-    static ArrayList mr = null;
+    private static ArrayList mr = null;
 
-    static ArrayList ds = null;
+    private static ArrayList ds = null;
 
     public static void add(String line) {
 
@@ -57,7 +57,7 @@
             StringBuffer mes1 = new StringBuffer();
 
             for (int i = 0; i < mr.size(); i++) {
-                mes1.append(mr.get(i).toString() + "\n");
+                mes1.append(mr.get(i).toString() + System.getProperty("line.separator"));
             }
             message += mes1;
         }
@@ -66,7 +66,7 @@
             StringBuffer mes2 = new StringBuffer();
 
             for (int i = 0; i < ds.size(); i++) {
-                mes2.append(ds.get(i).toString() + "\n");
+                mes2.append(ds.get(i).toString() + System.getProperty("line.separator"));
             }
             message += mes2;
         }
@@ -137,6 +137,96 @@
             mr = null;
         }
     }
+    
+    public static void send(String signURL, String email) {
+
+        String message = "";
+
+        if (mr != null) {
+
+            StringBuffer mes1 = new StringBuffer();
+
+            for (int i = 0; i < mr.size(); i++) {
+                mes1.append(mr.get(i).toString() + System.getProperty("line.separator"));
+            }
+            message += mes1;
+        }
+        if (ds != null) {
+
+            StringBuffer mes2 = new StringBuffer();
+
+            for (int i = 0; i < ds.size(); i++) {
+                mes2.append(ds.get(i).toString() + System.getProperty("line.separator"));
+            }
+            message += mes2;
+        }
+
+        if (Constants.MB_MAIL_SERVER != null
+                || !Constants.MB_MAIL_SERVER.equals("")
+                || Constants.MB_MAIL_PRGM != null
+                || !Constants.MB_MAIL_PRGM.equals("")) {
+
+            String to = "";
+            to = email;
+
+            if (to.equals("")) {
+                to = "edward.kawas at gmail.com";
+
+            }
+            String subject = "The RDFagent Report";
+            Log.info("email message is\n" + message);
+            if (Constants.MB_MAIL_PRGM != null
+                    || !Constants.MB_MAIL_PRGM.equals(""))
+                try {
+
+                    //String cmd ="echo \"" + message.toString() + "\" | "+
+                    // Constants.MB_MAIL_PRGM+ " -s 'The RDFagent Report :-(' '"
+                    // + "markw at illuminae.com"+ "'";
+                    String cmd = "echo \"" + message.toString() + "\" | "
+                            + Constants.MB_MAIL_PRGM
+                            + " -s 'The RDFagent Report :-(' '" + to + "'";
+                    File file = new File("_script_.sh");
+                    FileWriter fw = new FileWriter(file);
+                    fw.write(_shellScriptHeader + cmd);
+                    fw.close();
+
+                    Process p = Runtime.getRuntime().exec(
+                            "chmod +x _script_.sh");
+                    p.waitFor();
+                    p = Runtime.getRuntime().exec("./_script_.sh");
+                    InputStream stderr = p.getErrorStream();
+                    InputStreamReader isr = new InputStreamReader(stderr);
+                    BufferedReader br = new BufferedReader(isr);
+                    String line = null;
+                    while ((line = br.readLine()) != null) {
+
+                    }
+                    p.waitFor();
+                    Log.info("_script_.sh has "
+                            + ((file.delete()) ? "" : "not ") + "been deleted"
+                            + System.getProperty("line.separator")
+                            + "The exit value of the spawned process was : "
+                            + p.exitValue());
+                } catch (IOException e) {
+                    e.printStackTrace();
+                    Log.severe("Could not send message using cmd line mail to "
+                            + to);
+                    Report
+                            .doWrite("Could not send message using cmd line mail to "
+                                    + to);
+                    // use this only as a last resort
+                    if (Constants.MB_MAIL_SERVER != null
+                            || !Constants.MB_MAIL_SERVER.equals(""))
+                        Communicator.sendMail(to, subject, message.toString(),
+                                Constants.MB_FROM);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+            //Communicator.sendMail(to,subject,message.toString(),Constants.MB_FROM);
+            ds = null;
+            mr = null;
+        }
+    }
 
     public static void createFile(String fileName) {
         try {
@@ -197,5 +287,10 @@
     private final static String _shellScriptHeader = "#!/bin/sh"
             + System.getProperty("line.separator");
 
+	public static void clear() {
+        ds = null;
+        mr = null;
+	}
+
 }
 




More information about the MOBY-guts mailing list