[MOBY-guts] biomoby commit

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


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

Modified Files:
	Main.java 
Log Message:
added logic to enable the ability to provide a url that contains service descriptions and have the agent populate your registry with them

modified the logic of reporting

moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier Main.java,1.5,1.6
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Main.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Main.java	2005/08/04 12:58:41	1.5
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Main.java	2005/11/10 16:11:45	1.6
@@ -15,115 +15,126 @@
 /**
  * @author Nina Opushneva
  * 
- *  
+ * 
  */
 public class Main {
 
-    public static void main(String[] args) {
-        StringBuffer failedServices = new StringBuffer();
-        Log.start();
-
-        String report = Constants.RDFagentHome + Constants.SV_REPORT_PATH;
-        Report.createFile(report);
-
-        Date now = new Date();
-
-        Report
-                .doWrite("****************************************************************************************");
-        Report.doWrite("            START MOBY RDFAGENT REPORT   "
-                + now.toString());
-        Report
-                .doWrite("****************************************************************************************");
-
-        Report.add("            RDFAGENT REPORT          " + now.toString());
-        Report
-                .add("****************************************************************************************");
-
-        Hashtable serviceList = new Hashtable();
-        String signURL = "";
-        Calendar c = Calendar.getInstance();
-
-        if (args.length == 0) {
-
-            String delfile = Constants.RDFagentHome + Constants.SV_DELFILE_PATH;
-            Report.createFile(delfile);
-
-            //		  DataMngr.delServiceSetByURL(signURL);
-
-            String url_path = Constants.RDFagentHome
-                    + Constants.SV_SIGN_URL_PATH;
-
-            String filename = url_path + "_" + c.get(Calendar.DAY_OF_MONTH)
-                    + "_" + c.get(Calendar.MONTH);
-            Report.createFile(filename);
-            serviceList = DataMngr.getServices(filename);
-            /*
-             * }else if (args[0].equals("list")){ serviceList =
-             * Communicator.readFromFile(args[1]);
-             * 
-             * }else if (args[0].equals("sign")){
-             */
-        } else {
-
-            signURL = args[0];
-            serviceList = DataMngr.getServicesByURL(signURL);
-        }
-
-        Enumeration list = serviceList.keys();
-        while (list.hasMoreElements()) {
-            String ob = list.nextElement().toString();
-            String val = serviceList.get(ob).toString();
-            signURL = ob;
-            String servNames = val;
-
-            Model model = Communicator.getServiceRDF(servNames, signURL);
-
-            if (model.isEmpty()) {
-                Log.info("Model " + signURL + " is empty");
-                failedServices.append("__PATTERN__" + signURL); // something unique
-                                                           // that urls shouldnt
-                                                           // have
-            } else {
-                Report.add(" ");
-                Report.add("List of the processed services:");
-                ServiceDescrParser sdParser = new ServiceDescrParser(model);
-                sdParser.getValidRDF(servNames, signURL);
-
-            }
-            exit(failedServices.toString());
-            failedServices = new StringBuffer();
-        }
-        //		   }
-        if (args.length != 0) {
-            // TODO this line sends email
-            //Report.send(signURL);
-        }
-        //exit(failedServices.toString());
-    }
-
-    public static void exit(String signURL) {
-        DBConnector.closeConnection();
-
-        Log.stop();
-        Date now = new Date();
-        Report.doWrite("            STOP MOBY RDFAGENT REPORT          "
-                + now.toString());
-        Report.add("            STOP MOBY RDFAGENT REPORT          "
-                + now.toString());
-
-        Report
-                .doWrite("****************************************************************************************");
-
-        String[] failedURLs = signURL.split("__PATTERN__");
-        for (int i = 0; i < failedURLs.length; i++) {
-            if (!failedURLs[i].equals("")) {
-                Log
-                        .info("Sending an email to the individual identified by the following signature URL: "
-                                + failedURLs[i]);
-                Report.send(failedURLs[i]);
-            }
-        }
+	public static void main(String[] args) {
+		StringBuffer failedServices = new StringBuffer();
+		Log.start();
+		Date now = new Date();
+		Hashtable serviceList = new Hashtable();
+		String signURL = "";
+		String report = Constants.RDFagentHome + Constants.SV_REPORT_PATH;
+		Report.createFile(report);
+
+		Calendar c = Calendar.getInstance();
+
+		if (args.length == 0) {
+			Report
+					.doWrite("****************************************************************************************");
+			Report.doWrite("            START MOBY RDFAGENT REPORT   "
+					+ now.toString());
+			Report
+					.doWrite("****************************************************************************************");
+
+			Report
+					.add("            RDFAGENT REPORT          "
+							+ now.toString());
+			Report
+					.add("****************************************************************************************");
+			String delfile = Constants.RDFagentHome + Constants.SV_DELFILE_PATH;
+			Report.createFile(delfile);
+
+			// DataMngr.delServiceSetByURL(signURL);
+
+			String url_path = Constants.RDFagentHome
+					+ Constants.SV_SIGN_URL_PATH;
+
+			String filename = url_path + "_" + c.get(Calendar.DAY_OF_MONTH)
+					+ "_" + c.get(Calendar.MONTH);
+			Report.createFile(filename);
+			serviceList = DataMngr.getServices(filename);
+			/*
+			 * }else if (args[0].equals("list")){ serviceList =
+			 * Communicator.readFromFile(args[1]);
+			 * 
+			 * }else if (args[0].equals("sign")){
+			 */
+		} else if (args.length == 1){
+			signURL = args[0];
+			Log.info("Getting services from " + signURL);
+			// serviceList = DataMngr.getServicesByURL(signURL);
+			Model model = Communicator.getServiceRDF("", signURL);
+			Report.clear();
+			if (model.isEmpty()) {
+				Log.info("Model " + signURL + " is empty");
+				// not important
+			} else {
+				ServiceDescrParser sdParser = new ServiceDescrParser(model);
+				sdParser.addServicesFromRdfDocument(signURL, Constants.MB_ADMIN_EMAIL);
+
+			}
+			Report.clear();
+			return;
+
+		} else {
+			Log.severe("Incorrect usage of the agent. Please enter a url where services can be found as a parameter or run the agent without parameters.");
+			return;
+			
+		}
+
+		Enumeration list = serviceList.keys();
+		while (list.hasMoreElements()) {
+			String ob = list.nextElement().toString();
+			String val = serviceList.get(ob).toString();
+			signURL = ob;
+			String servNames = val;
+
+			Model model = Communicator.getServiceRDF(servNames, signURL);
+
+			if (model.isEmpty()) {
+				Log.info("Model " + signURL + " is empty");
+				failedServices.append("__PATTERN__" + signURL); // something
+																// unique
+				// that urls shouldnt
+				// have
+			} else {
+				Report.add(" ");
+				Report.add("List of the processed services:");
+				ServiceDescrParser sdParser = new ServiceDescrParser(model);
+				sdParser.getValidRDF(servNames, signURL);
+
+			}
+			exit(failedServices.toString());
+			failedServices = new StringBuffer();
+		}
+		Report.clear();
+	}
+
+	public static void exit(String signURL) {
+		DBConnector.closeConnection();
+
+		Log.stop();
+		Date now = new Date();
+		Report.doWrite("            STOP MOBY RDFAGENT REPORT          "
+				+ now.toString());
+		Report.add("            STOP MOBY RDFAGENT REPORT          "
+				+ now.toString());
+
+		Report
+				.doWrite("****************************************************************************************");
+
+		String[] failedURLs = signURL.split("__PATTERN__");
+		for (int i = 0; i < failedURLs.length; i++) {
+			if (!failedURLs[i].equals("")) {
+				Log
+						.info("Sending an email to the individual identified by the following signature URL: "
+								+ failedURLs[i]);
+				Report.send(failedURLs[i]);
+			}
+		}
 
-        //System.exit(0);
-    }
+		// System.exit(0);
+	}
 }
\ No newline at end of file




More information about the MOBY-guts mailing list