[MOBY-guts] biomoby commit

Eddie Kawas kawas at pub.open-bio.org
Thu Jul 28 15:22:00 UTC 2005


kawas
Thu Jul 28 11:22:00 EDT 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier
In directory pub.open-bio.org:/tmp/cvs-serv3877/org/biomoby/registry/rdfagent/verifier

Modified Files:
	Communicator.java 
Log Message:
Changes made were only to formatting of code (i think!?!).

moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier Communicator.java,1.5,1.6
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Communicator.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/Communicator.java	2005/06/13 18:14:35	1.5
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Communicator.java	2005/07/28 15:22:00	1.6
@@ -34,250 +34,263 @@
  */
 public class Communicator {
 
-	/**
-	 * get RDF model of service by signatureURL (make HTTP connect to server,
-	 * open a file,read a file into a streem, build the model)
-	 * 
-	 * @param signURL -
-	 *            the URL of resource (signatureURL)
-	 * @param servNames -
-	 *            set of service names located at this signatureURL
-	 * @return Model the RDF model of services located at this signatureURL
-	 */
-
-	public static Model getServiceRDF(String servNames, String signURL) {
-
-		Model model = ModelFactory.createDefaultModel();
-		String mes1 = "";
-		try {
-			URL u = new URL(signURL);
-
-			HttpURLConnection huc = (HttpURLConnection) u.openConnection();
-			huc.connect();
-
-			int code = huc.getResponseCode();
-			Log.info("GET   <" + signURL + " >  - HTTP CODE: " + code);
-			Report.doWrite("");
-			Report.doWrite("GET SIGNATURE_URL  <" + signURL
-					+ " >  - HTTP CODE: " + code);
-			Report.add("GET SIGNATURE_URL  <" + signURL + " >  - HTTP CODE: "
-					+ code);
-			if (code == 200 || code == 202) {
-
-				try {
-					model.read(huc.getInputStream(), "");
-				} catch (RDFException e) {
-					Log.severe("Failed : " + e);
-					Report.add("Error 1: " + e);
-					
-
-					//                    e.getMessage();
-				} catch (JenaException e) {
-					//reset code to
-					code = 417;
-				}
-				//http://www.w3.org/RDF/Validator/RDF/Validator/ARPServlet?URI=
-			}
-			
-			//////////////////////////
-			// no else if here purposely, because i reset the code if an
-			// exception is thrown due to invalid rdfs being returned.
-			//////////////////////////
-			if (code != 200 && code != 202)
-				if (code == 400) {
-					Log
-							.warning("The request had bad syntax or was inherently impossible to be satisfied.");
-					Report
-							.add("The request had bad syntax or was inherently impossible to be satisfied.");
-				} else if (code == 401) {
-					Log
-							.warning("The parameter to this message gives a specification of authorization schemes which are acceptable.");
-					Report
-							.add("The parameter to this message gives a specification of authorization schemes which are acceptable.");
-				} else if (code == 402) {
-					Report
-							.add("The parameter to this message gives a specification of charging schemes acceptable.");
-				} else if (code == 403) {
-					Report
-							.add("The request is for something forbidden. Authorization will not help.");
-					mes1 = "The request is for something forbidden.";
-				} else if (code == 404) {
-					Report
-							.doWrite("The server has not found anything matching the URI given");
-					Report
-							.add("The server has not found anything matching the URI given");
-					mes1 = "The RDF file was not found on the server";
-				} else if (code == 417) {
-					Report.add(" RDF Parsing error. Possible reason being that multiple <rdf:RDF> tags found in the same file.");
-					mes1 = " RDF Parsing error. Multiple <rdf:RDF> tags found.";
-				} else if (code == 500) {
-					Report.add(" Internal Error");
-					mes1 = " Internal Error";
-				}
-			int num = DataMngr.getServErrorNum(signURL, code);
-
-			if (num > 0) {
-				if (num < 3) {
-					DataMngr.updErrCount(signURL, code);
-				} else {
-
-					String servList = DataMngr.getServListByURL(signURL);
-					String s[] = servList.split(",");
-					Report.add("THE CONNECT TO   < " + signURL
-							+ " >  WAS REFUSED WITH HTTP CODE " + code
-							+ " THREE TIMES IN ROW. ");
-					Report
-							.add("THE SERVICES LOCATED AT  < "
-									+ signURL
-									+ " >  WILL BE DEREGISTERED FROM mobycentral REGISTRY.");
-					String m1 = "THE CONNECT TO   < " + signURL
-							+ " >  WAS REFUSED WITH HTTP CODE " + code
-							+ " THREE TIMES IN ROW. ";
-					String m2 = "THE SERVICES LOCATED AT  < "
-							+ signURL
-							+ " >  WILL BE DEREGISTERED FROM mobycentral REGISTRY.";
-					String msg = m1 + " " + m2;
-
-					Report.doWrite("DELETED SERVICES :");
-					for (int i = s.length - 1; i >= 0; i--) {
-						Report.doWrite(i + ". " + s[i]);
-					}
-					DataMngr.delServiceSetByURL(signURL);
-					DataMngr.delServErrors(signURL);
-					Report.add("THE CONNECT TO   < " + signURL
-							+ " >  WAS REFUSED WITH HTTP CODE " + code
-							+ " THREE TIMES IN ROW. ");
-					Report
-							.add("THE SERVICES LOCATED AT  < "
-									+ signURL
-									+ " >  WILL BE DEREGISTERED FROM mobycentral REGISTRY");
-					Report
-							.doWrite("=======================================================================================");
-				}
-
-			} else {
-				DataMngr.insErrCount(signURL, code);
-			}
-			huc.disconnect();
-		} catch (IOException e) {
-			Log.severe("Failed : " + e);
-			Report.add("Error 2: " + e);
-			//			e.getMessage();
-		}
-
-		return model;
-
-	}
-
-	/**
-	 * a SMTP client that allows The SMTP client establishes a connection with
-	 * an SMTP server and waits for the server to respond . The client is then
-	 * ready to construct a mail message. (make HTTP connect to server, open a
-	 * file,read a file into a streem, build a model)
-	 * 
-	 * @param to -
-	 *            where is the target of the e-mail message to be sent.
-	 * @param subj -
-	 *            the subject of this MailMessage.
-	 * @param msgStr -
-	 *            the text data that is to be included in this MailMessage.
-	 * @param from -
-	 *            where is the e-mail address of the message transmitter.
-	 *  
-	 */
-
-	public static void sendMail(String to, String subj, String msgStr,
-			String from) {
-
-		try {
-
-			Properties prop = new Properties();
-			prop.put("mail.smtp.host", Constants.MB_MAIL_SERVER);
-			Session ses = Session.getDefaultInstance(prop, null);
-			MimeMessage msg = new MimeMessage(ses);
-			msg.setFrom(new InternetAddress(from));
-			msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
-			msg.setSubject(subj);
-			msg.setSentDate(new Date());
-			msg.setText(msgStr);
-			if (Constants.MB_MAIL_PSWD != null) {
-				Transport transport = ses.getTransport("smtp"); //for usage a
-																// password
-				transport.connect(Constants.MB_MAIL_SERVER,
-						Constants.MB_MAIL_USER, Constants.MB_MAIL_PSWD);
-			}
-			Transport.send(msg);
-			Report.doWrite("The message have been sent to " + to);
-		} catch (MessagingException e) {
-			//			Log.severe(e.getMessage()+" sendmail");
-			e.getMessage();
-		}
-
-	}
-
-	public static String readFromURL(String url) {
-		String list = "";
-		try {
-			URL u = new URL(url);
-
-			HttpURLConnection huc = (HttpURLConnection) u.openConnection();
-			huc.connect();
-
-			int code = huc.getResponseCode();
-			Log.info("GET   <" + url + " >  - HTTP CODE: " + code);
-			Report.doWrite("");
-			Report.doWrite("GET SIGNATURE_URL  <" + url + " >  - HTTP CODE: "
-					+ code);
-			Report.add("GET SIGNATURE_URL  <" + url + " >  - HTTP CODE: "
-					+ code);
-
-			if (code == 200 || code == 202) {
-
-			} else {
-
-			}
-		} catch (IOException e) {
-			Log.severe("Failed : " + e);
-			Report.add("Error 2: " + e);
-			//			  e.getMessage();
-		}
-		return list;
-	}
-
-	public static Hashtable readFromFile(String file) {
-
-		Hashtable list = new Hashtable();
-		//...checks on aFile are elided
-		//		StringBuffer contents = new StringBuffer();
-
-		//declared here only to make visible to finally clause
-		BufferedReader input = null;
-		try {
-			//use buffering
-			//this implementation reads one line at a time
-			input = new BufferedReader(new FileReader(file));
-			String line = null; //not declared within while loop
-			while ((line = input.readLine()) != null) {
-				list.put(line, "");
-				//			contents.append(line);
-				//			contents.append(System.getProperty("line.separator"));
-			}
-		} catch (FileNotFoundException ex) {
-			ex.printStackTrace();
-		} catch (IOException ex) {
-			ex.printStackTrace();
-		} finally {
-			try {
-				if (input != null) {
-					//flush and close both "input" and its underlying
-					// FileReader
-					input.close();
-				}
-			} catch (IOException ex) {
-				ex.printStackTrace();
-			}
-		}
-		return list;
-	}
+    /**
+     * get RDF model of service by signatureURL (make HTTP connect to server,
+     * open a file,read a file into a streem, build the model)
+     * 
+     * @param signURL -
+     *            the URL of resource (signatureURL)
+     * @param servNames -
+     *            set of service names located at this signatureURL
+     * @return Model the RDF model of services located at this signatureURL
+     */
+
+    public static Model getServiceRDF(String servNames, String signURL) {
+
+        Model model = ModelFactory.createDefaultModel();
+        String mes1 = "";
+        try {
+            URL u = new URL(signURL);
+
+            HttpURLConnection huc = (HttpURLConnection) u.openConnection();
+            huc.connect();
+
+            int code = huc.getResponseCode();
+            Log.info("GET   <" + signURL + " >  - HTTP CODE: " + code);
+            Report.doWrite("");
+            Report.doWrite("GET SIGNATURE_URL  <" + signURL
+                    + " >  - HTTP CODE: " + code);
+            Report.add("GET SIGNATURE_URL  <" + signURL + " >  - HTTP CODE: "
+                    + code);
+            if (code == 200 || code == 202) {
+                try {
+                    model.read(huc.getInputStream(), "");
+                    DataMngr.delServErrors(signURL);
+                } catch (RDFException e) {
+                    Log.severe("Failed : " + e);
+                    Report.add("Error 1: " + e);
+                    // reset code in instances that domain is valid, but nothing returned.
+                    code = 404;
+                    //                    e.getMessage();
+                } catch (JenaException e) {
+                    //reset code to
+                    code = 417;
+                }
+                //http://www.w3.org/RDF/Validator/RDF/Validator/ARPServlet?URI=
+            }
+
+            //////////////////////////
+            // no else if here purposely, because i reset the code if an
+            // exception is thrown due to invalid rdfs being returned.
+            //////////////////////////
+            if (code != 200 && code != 202) {
+                if (code == 400) {
+                    Log
+                            .warning("The request had bad syntax or was inherently impossible to be satisfied.");
+                    Report
+                            .add("The request had bad syntax or was inherently impossible to be satisfied.");
+                } else if (code == 401) {
+                    Log
+                            .warning("The parameter to this message gives a specification of authorization schemes which are acceptable.");
+                    Report
+                            .add("The parameter to this message gives a specification of authorization schemes which are acceptable.");
+                } else if (code == 402) {
+                    Report
+                            .add("The parameter to this message gives a specification of charging schemes acceptable.");
+                } else if (code == 403) {
+                    Report
+                            .add("The request is for something forbidden. Authorization will not help.");
+                    mes1 = "The request is for something forbidden.";
+                } else if (code == 404) {
+                    Report
+                            .doWrite("The server has not found anything matching the URI given");
+                    Report
+                            .add("The server has not found anything matching the URI given");
+                    mes1 = "The RDF file was not found on the server";
+                } else if (code == 417) {
+                    Report
+                            .add(" RDF Parsing error. Possible reason being that multiple <rdf:RDF> tags found in the same file.");
+                    mes1 = "RDF Parsing error. Possible reason being that multiple <rdf:RDF> tags found in the same file.";
+                } else if (code == 500) {
+                    Report.add(" Internal Error");
+                    mes1 = " Internal Error";
+                }
+                int num = DataMngr.getServErrorNum(signURL, code);
+
+                updateNumCount(signURL, code, num);
+            }
+            huc.disconnect();
+        } catch (IOException e) {
+            Log.severe("Failed : " + e);
+            Report.add("Error 2: " + e);
+            int code = 404;
+            int num = DataMngr.getServErrorNum(signURL, code);
+            updateNumCount(signURL, code, num);
+        }
+        return model;
+
+    }
+
+    /**
+     * @param signURL
+     * @param code
+     * @param num
+     */
+    private static void updateNumCount(String signURL, int code, int num) {
+        if (num > 0) {
+            if (num < 3) {
+                DataMngr.updErrCount(signURL, code);
+            } else {
+
+                String servList = DataMngr.getServListByURL(signURL);
+                String s[] = servList.split(",");
+                Report.add("THE CONNECT TO   < " + signURL
+                        + " >  WAS REFUSED WITH HTTP CODE " + code
+                        + " THREE TIMES IN ROW. ");
+                Report
+                        .add("THE SERVICES LOCATED AT  < "
+                                + signURL
+                                + " >  WILL BE DEREGISTERED FROM mobycentral REGISTRY.");
+                String m1 = "THE CONNECT TO   < " + signURL
+                        + " >  WAS REFUSED WITH HTTP CODE " + code
+                        + " THREE TIMES IN ROW. ";
+                String m2 = "THE SERVICES LOCATED AT  < "
+                        + signURL
+                        + " >  WILL BE DEREGISTERED FROM mobycentral REGISTRY.";
+                String msg = m1 + " " + m2;
+
+                Report.doWrite("DELETED SERVICES :");
+                for (int i = s.length - 1; i >= 0; i--) {
+                    Report.doWrite(i + ". " + s[i]);
+                }
+                DataMngr.delServiceSetByURL(signURL);
+                DataMngr.delServErrors(signURL);
+                Report.add("THE CONNECT TO   < " + signURL
+                        + " >  WAS REFUSED WITH HTTP CODE " + code
+                        + " THREE TIMES IN ROW. ");
+                Report
+                        .add("THE SERVICES LOCATED AT  < "
+                                + signURL
+                                + " >  WILL BE DEREGISTERED FROM mobycentral REGISTRY");
+                Report
+                        .doWrite("=======================================================================================");
+                // TODO send the report here?
+            }
+
+        } else {
+            DataMngr.insErrCount(signURL, code);
+        }
+    }
+
+    /**
+     * a SMTP client that allows The SMTP client establishes a connection with
+     * an SMTP server and waits for the server to respond . The client is then
+     * ready to construct a mail message. (make HTTP connect to server, open a
+     * file,read a file into a streem, build a model)
+     * 
+     * @param to -
+     *            where is the target of the e-mail message to be sent.
+     * @param subj -
+     *            the subject of this MailMessage.
+     * @param msgStr -
+     *            the text data that is to be included in this MailMessage.
+     * @param from -
+     *            where is the e-mail address of the message transmitter.
+     *  
+     */
+
+    public static void sendMail(String to, String subj, String msgStr,
+            String from) {
+
+        try {
+
+            Properties prop = new Properties();
+            prop.put("mail.smtp.host", Constants.MB_MAIL_SERVER);
+            Session ses = Session.getDefaultInstance(prop, null);
+            MimeMessage msg = new MimeMessage(ses);
+            msg.setFrom(new InternetAddress(from));
+            msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
+            msg.setSubject(subj);
+            msg.setSentDate(new Date());
+            msg.setText(msgStr);
+            if (Constants.MB_MAIL_PSWD != null) {
+                Transport transport = ses.getTransport("smtp"); //for usage a
+                // password
+                transport.connect(Constants.MB_MAIL_SERVER,
+                        Constants.MB_MAIL_USER, Constants.MB_MAIL_PSWD);
+            }
+            Transport.send(msg);
+            Report.doWrite("The message have been sent to " + to);
+        } catch (MessagingException e) {
+            //			Log.severe(e.getMessage()+" sendmail");
+            e.getMessage();
+        }
+
+    }
+
+    public static String readFromURL(String url) {
+        String list = "";
+        try {
+            URL u = new URL(url);
+
+            HttpURLConnection huc = (HttpURLConnection) u.openConnection();
+            huc.connect();
+
+            int code = huc.getResponseCode();
+            Log.info("GET   <" + url + " >  - HTTP CODE: " + code);
+            Report.doWrite("");
+            Report.doWrite("GET SIGNATURE_URL  <" + url + " >  - HTTP CODE: "
+                    + code);
+            Report.add("GET SIGNATURE_URL  <" + url + " >  - HTTP CODE: "
+                    + code);
+
+            if (code == 200 || code == 202) {
+
+            } else {
+
+            }
+        } catch (IOException e) {
+            Log.severe("Failed : " + e);
+            Report.add("Error 2: " + e);
+            //			  e.getMessage();
+        }
+        return list;
+    }
+
+    public static Hashtable readFromFile(String file) {
+
+        Hashtable list = new Hashtable();
+        //...checks on aFile are elided
+        //		StringBuffer contents = new StringBuffer();
+
+        //declared here only to make visible to finally clause
+        BufferedReader input = null;
+        try {
+            //use buffering
+            //this implementation reads one line at a time
+            input = new BufferedReader(new FileReader(file));
+            String line = null; //not declared within while loop
+            while ((line = input.readLine()) != null) {
+                list.put(line, "");
+                //			contents.append(line);
+                //			contents.append(System.getProperty("line.separator"));
+            }
+        } catch (FileNotFoundException ex) {
+            ex.printStackTrace();
+        } catch (IOException ex) {
+            ex.printStackTrace();
+        } finally {
+            try {
+                if (input != null) {
+                    //flush and close both "input" and its underlying
+                    // FileReader
+                    input.close();
+                }
+            } catch (IOException ex) {
+                ex.printStackTrace();
+            }
+        }
+        return list;
+    }
 
 }
\ No newline at end of file




More information about the MOBY-guts mailing list