[MOBY-guts] biomoby commit
Eddie Kawas
kawas at pub.open-bio.org
Mon Sep 12 18:22:10 UTC 2005
kawas
Mon Sep 12 14:22:10 EDT 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util
In directory pub.open-bio.org:/tmp/cvs-serv9124/org/biomoby/registry/rdfagent/util
Modified Files:
Report.java Constants.java
Log Message:
made various bug fixes and added a sendmail option for sending out the results to service providers.
moby-live/Java/src/main/org/biomoby/registry/rdfagent/util Report.java,1.6,1.7 Constants.java,1.6,1.7
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java 2005/08/04 12:58:40 1.6
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java 2005/09/12 18:22:10 1.7
@@ -8,7 +8,7 @@
/**
* @author Nina Opushneva
- *
+ *
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
@@ -22,132 +22,170 @@
import org.biomoby.registry.rdfagent.verifier.DataMngr;
public class Report {
-
- static ArrayList mr = null;
+
+ static ArrayList mr = null;
+
static ArrayList ds = null;
-
- public static void add(String line){
-
- if(mr == null){
- mr = new ArrayList();
- }
- mr.add(line);
-
- }
-
- public static void doBuild(String line){
-
- if(ds == null){
- ds = new ArrayList();
- }
- ds.add(line);
-
- }
-
- public static void send(String signURL){
-
- String message = "";
-
- if(mr != null){
-
- StringBuffer mes1 = new StringBuffer();
-
- for (int i=0; i < mr.size(); i++){
- mes1.append(mr.get(i).toString()+"\n");
- }
- message += mes1;
- }
- if(ds != null){
-
- StringBuffer mes2 = new StringBuffer();
-
- for (int i=0; i < ds.size(); i++){
- mes2.append(ds.get(i).toString()+"\n");
- }
- message += mes2;
- }
-
- if (Constants.MB_MAIL_SERVER != null || !Constants.MB_MAIL_SERVER.equals("") ){
-
- String to = "";
- to = DataMngr.getContactEmail(signURL);
-
- if (to.equals("")){
- to = "edward.kawas at gmail.com";
-
- }
- String subject = "The RDFagent Report";
- Log.info("email message is\n" + message);
- Communicator.sendMail(to,subject,message.toString(),Constants.MB_FROM); // send message to the service provider - that service was deregistered
- ds = null;
- mr = null;
- }
- }
-
- public static void createFile(String fileName){
- try {
- File file = new File(fileName);
-
- // Create file if it does not exist
- boolean success = file.createNewFile();
- if (success) {
- // File did not exist and was created
- } else {
- // File already exists
- file.delete();
- file.createNewFile();
- }
- } catch (IOException e) {
- Log.warning(e.getMessage());
- }
- }
-
- public static void doWrite(String line) {
-
- try {
- String path = Constants.RDFagentHome;
- BufferedWriter out = new BufferedWriter(new FileWriter(path+Constants.SV_REPORT_PATH, true));
- out.write(line);
- out.newLine();
- out.close();
- } catch (IOException e) {
- Log.warning(e.getMessage());
- }
-
- }
-
-/* public static void doBuild(String line) {
-
- try {
- String path = Constants.RDFagentHome;
- BufferedWriter out = new BufferedWriter(new FileWriter(path+Constants.SV_DELFILE_PATH, true));
- out.write(line);
- out.newLine();
- out.close();
- } catch (IOException e) {
- Log.warning(e.getMessage());
- }
-
- }
-*/
-
- public static void doSave(String file,String line) {
-
- try {
-
- BufferedWriter out = new BufferedWriter(new FileWriter(file, true));
- out.write(line);
- out.newLine();
- out.close();
- } catch (IOException e) {
- Log.warning(e.getMessage());
- }
-
- }
-
-
- }
+ public static void add(String line) {
+
+ if (mr == null) {
+ mr = new ArrayList();
+ }
+ mr.add(line);
+
+ }
+
+ public static void doBuild(String line) {
+
+ if (ds == null) {
+ ds = new ArrayList();
+ }
+ ds.add(line);
+
+ }
+
+ public static void send(String signURL) {
+
+ String message = "";
+
+ if (mr != null) {
+
+ StringBuffer mes1 = new StringBuffer();
+
+ for (int i = 0; i < mr.size(); i++) {
+ mes1.append(mr.get(i).toString() + "\n");
+ }
+ message += mes1;
+ }
+ if (ds != null) {
+
+ StringBuffer mes2 = new StringBuffer();
+
+ for (int i = 0; i < ds.size(); i++) {
+ mes2.append(ds.get(i).toString() + "\n");
+ }
+ 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 = DataMngr.getContactEmail(signURL);
+
+ 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");
+ 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 {
+ File file = new File(fileName);
+
+ // Create file if it does not exist
+ boolean success = file.createNewFile();
+ if (success) {
+ // File did not exist and was created
+ } else {
+ // File already exists
+ file.delete();
+ file.createNewFile();
+ }
+ } catch (IOException e) {
+ Log.warning(e.getMessage());
+ }
+ }
+
+ public static void doWrite(String line) {
+
+ try {
+ String path = Constants.RDFagentHome;
+ BufferedWriter out = new BufferedWriter(new FileWriter(path
+ + Constants.SV_REPORT_PATH, true));
+ out.write(line);
+ out.newLine();
+ out.close();
+ } catch (IOException e) {
+ Log.warning(e.getMessage());
+ }
+
+ }
+
+ /*
+ * public static void doBuild(String line) {
+ *
+ * try { String path = Constants.RDFagentHome; BufferedWriter out = new
+ * BufferedWriter(new FileWriter(path+Constants.SV_DELFILE_PATH, true));
+ * out.write(line); out.newLine(); out.close(); } catch (IOException e) {
+ * Log.warning(e.getMessage()); } }
+ */
+
+ public static void doSave(String file, String line) {
+
+ try {
+
+ BufferedWriter out = new BufferedWriter(new FileWriter(file, true));
+ out.write(line);
+ out.newLine();
+ out.close();
+ } catch (IOException e) {
+ Log.warning(e.getMessage());
+ }
+
+ }
+ private final static String _shellScriptHeader = "#!/bin/sh"
+ + System.getProperty("line.separator");
+}
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Constants.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Constants.java 2005/04/16 14:32:47 1.6
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Constants.java 2005/09/12 18:22:10 1.7
@@ -40,6 +40,7 @@
public static String MB_MAIL_USER = null;
public static String MB_MAIL_PSWD = null;
public static String MB_FROM = null;
+ public static String MB_MAIL_PRGM = null;
public static String SP_SUBJECT = null;
public static String SP_ERR_MSG_CON = null;
@@ -78,6 +79,7 @@
MB_SUBJECT = moby.getChildTextTrim("subject");
MB_ERR_MSG = moby.getChildTextTrim("errMessage");
MB_MAIL_SERVER = moby.getChildTextTrim("mailServer");
+ MB_MAIL_PRGM = moby.getChildTextTrim("cmdLnMailProgram");
MB_MAIL_USER = moby.getChildTextTrim("mailUser");
MB_MAIL_PSWD = moby.getChildTextTrim("mailPswd");
MB_FROM = moby.getChildTextTrim("from");
More information about the MOBY-guts
mailing list