[MOBY-guts] biomoby commit

Nina Opushneva nopushneva at pub.open-bio.org
Thu Apr 14 16:45:37 UTC 2005


nopushneva
Thu Apr 14 12:45:37 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-serv12921

Modified Files:
	DBConnector.java Report.java XMLBuilder.java 
Log Message:
recent version

moby-live/Java/src/main/org/biomoby/registry/rdfagent/util DBConnector.java,1.1,1.2 Report.java,1.1,1.2 XMLBuilder.java,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/DBConnector.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/DBConnector.java	2004/10/28 17:55:43	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/DBConnector.java	2005/04/14 16:45:37	1.2
@@ -1,153 +1,155 @@
-package org.biomoby.registry.rdfagent.util;
-
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
-
-/**
- * @author Nina Opushneva
- *
- * Establish a connection with a database 
- */
-
-public class DBConnector
- {
-	private static String url = Constants.DB_URL; 
-	private static String driverClassName = Constants.DB_DRIVER_CLASS; 
-	private static String dbUserName = Constants.DB_USER;
-	private static String dbPwd = Constants.DB_PASSWD;
-
-
-
-
-	public static Connection con;
-
-	/** get a connect to database
-		* 
-		* @return Connection 
-		* If the connection doesn't exists, get the new connection
-		* If the connection exists but have been closed, get the new connection
-		* Something wrong with the existing connection, get new one
-		*/	
-
-    public static Connection getConnection()
-    {
-
-        if (con == null) //If the connection doesn't exists, get the new connection
-        {
-            con = getNewConnection();
-        }
-        else
-        {
-            try {
-                if(con.isClosed()) // If the connection exists but have been closed, get the new connection
-                {
-                    con = getNewConnection();
-                }
-            }
-            catch (SQLException e) // Something wrong with the existing connection, get new one
-            {
-				Log.info(e.getMessage());
-                con = getNewConnection();                
-            }
-        }
-      return con;
-    }
-
-
- 	/** close a connect to database
-		*
-		*/
-
-    public static void closeConnection()
-    {
-        if (con != null) //If the connection exists, try to close it
-        {
-
-            try
-            {
-                con.close();
-            }
-            catch (SQLException e)
-            {
-              Log.severe(e.getMessage());
-                // do nothing
-            }
-        }
-    }
-
-/** set a database User name			 
-	* @param userName - the name of user
-	* 
-*/	
-
-    public static void setDBUserName(final String userName){
-        dbUserName = userName;
-    }
-
-
-/** set a database password			 
-		* @param password - the database password
-		* 
-	*/	
-
-    public static void setDBPassword(final String password){
-        dbPwd = password;
-    }
-
-
-/** set an URL		 
-		* @param URL - URL address for a database
-		* 
-	*/	
-
-    public static void setURL(final String URL){
-        url = URL;
-    }
-
-
-	/** set a Driver class			 
-		* @param driverClass - the name of Driver class
-		* 
-	*/	
-
-    public static void setDriverClass(final String driverClass){
-        driverClassName = driverClass;
-    }
-
-
-/** get a new connection		 
-		* 
-		* 
-	*/	
-
-    private static Connection getNewConnection()
-    {
-
-        try
-        {
-            Class.forName(driverClassName);
-        }
-        catch(ClassNotFoundException e)
-        {
- //           e.printStackTrace();
-            Log.severe(e.getMessage());
-        }
-
-        try
-        {
-            con = DriverManager.getConnection(url, dbUserName, dbPwd);
-        }
-        catch (SQLException e)
-        {
-             Log.severe(e.getMessage());
-        }
-
-        return con;
-    }
-
-
-
-}
+package org.biomoby.registry.rdfagent.util;
+
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+
+/**
+ * @author Nina Opushneva
+ *
+ * Establish a connection with a database 
+ */
+
+public class DBConnector
+ {
+	private static String url = Constants.DB_URL; 
+	private static String driverClassName = Constants.DB_DRIVER_CLASS; 
+	private static String dbUserName = Constants.DB_USER;
+	private static String dbPwd = Constants.DB_PASSWD;
+
+
+
+
+	public static Connection con;
+
+	/** get a connect to database
+		* 
+		* @return Connection 
+		* If the connection doesn't exists, get the new connection
+		* If the connection exists but have been closed, get the new connection
+		* Something wrong with the existing connection, get new one
+		*/	
+
+    public static Connection getConnection()
+    {
+
+        if (con == null) //If the connection doesn't exists, get the new connection
+        {
+            con = getNewConnection();
+        }
+        else
+        {
+            try {
+                if(con.isClosed()) // If the connection exists but have been closed, get the new connection
+                {
+                    con = getNewConnection();
+                }
+            }
+            catch (SQLException e) // Something wrong with the existing connection, get new one
+            {
+				Log.info(e.getMessage());
+//				e.getMessage();	
+                con = getNewConnection();                
+            }
+        }
+      return con;
+    }
+
+
+ 	/** close a connect to database
+		*
+		*/
+
+    public static void closeConnection()
+    {
+        if (con != null) //If the connection exists, try to close it
+        {
+
+            try
+            {
+                con.close();
+            }
+            catch (SQLException e)
+            {
+              Log.severe(e.getMessage());
+//                e.getMessage();	
+            }
+        }
+    }
+
+/** set a database User name			 
+	* @param userName - the name of user
+	* 
+*/	
+
+    public static void setDBUserName(final String userName){
+        dbUserName = userName;
+    }
+
+
+/** set a database password			 
+		* @param password - the database password
+		* 
+	*/	
+
+    public static void setDBPassword(final String password){
+        dbPwd = password;
+    }
+
+
+/** set an URL		 
+		* @param URL - URL address for a database
+		* 
+	*/	
+
+    public static void setURL(final String URL){
+        url = URL;
+    }
+
+
+	/** set a Driver class			 
+		* @param driverClass - the name of Driver class
+		* 
+	*/	
+
+    public static void setDriverClass(final String driverClass){
+        driverClassName = driverClass;
+    }
+
+
+/** get a new connection		 
+		* 
+		* 
+	*/	
+
+    private static Connection getNewConnection()
+    {
+
+        try
+        {
+            Class.forName(driverClassName);
+        }
+        catch(ClassNotFoundException e)
+        {
+//           e.printStackTrace();
+            Log.severe(e.getMessage());
+        }
+
+        try
+        {     	
+            con = DriverManager.getConnection(url, dbUserName, dbPwd);
+        }
+        catch (SQLException e)
+        {
+             Log.severe(e.getMessage());
+//          e.getMessage();	
+        }
+
+        return con;
+    }
+
+
+
+}

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java	2004/10/28 17:55:43	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java	2005/04/14 16:45:37	1.2
@@ -16,10 +16,71 @@
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.File;
+import java.util.ArrayList;
 
+import org.biomoby.registry.rdfagent.util.*;
+import org.biomoby.registry.rdfagent.verifier.*;
 
 public class Report {
 	
+	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 = "opushneva at yahoo.ca";
+		 
+		  }
+		  String subject = "The RDFagent Report";
+		  Communicator.sendMail(to,subject,message.toString(),Constants.MB_FROM); // send message to the service provider - that service was deregistered		
+		}	
+	}
+	
 	public static void createFile(String fileName){
 		try {
 			   File file = new File(fileName);
@@ -34,6 +95,7 @@
 				   file.createNewFile();
 			   }
 		   } catch (IOException e) {
+			Log.warning(e.getMessage());	
 		   }
 	}
 		
@@ -46,11 +108,12 @@
 	   out.newLine();
 	   out.close();
    } catch (IOException e) {
+	Log.warning(e.getMessage());	
    }
    
     }
     
-	public static void doBuild(String line) {
+/*	public static void doBuild(String line) {
   
 		try {
 		String path = Constants.RDFagentHome;	
@@ -59,10 +122,11 @@
 	   out.newLine();
 	   out.close();
    } catch (IOException e) {
+	     Log.warning(e.getMessage());	
    }
    
 	}
-
+*/
 
 	public static void doSave(String file,String line) {
   
@@ -73,6 +137,7 @@
 		   out.newLine();
 		   out.close();
 	   } catch (IOException e) {
+		   Log.warning(e.getMessage());	
 	   }
    
 		}

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/XMLBuilder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/XMLBuilder.java	2005/04/07 22:31:34	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/XMLBuilder.java	2005/04/14 16:45:37	1.3
@@ -31,6 +31,7 @@
     openInpOut("Input");
     int authId = DataMngr.getAuthIdByServNameAndSignURL(servName,signURL);
     int servInstId = DataMngr.getServInstId(servName,authId);
+//System.out.println("servInstId = "+servInstId);    
     DataMngr.getSimpleCollectInput(servInstId);	 
 	DataMngr.getSecondary(servInstId);   
     closeInpOut("Input");
@@ -83,8 +84,10 @@
 
 	if (nsType!=null){
 		String[] result = nsType.split(",");
-		for (int i=0; i<result.length; i++) {	
+		for (int i=0; i<result.length; i++) {
+		 if (!result[i].equals("")){		 
 	      Report.doBuild("         <namespace_type_uris>"+result[i]+"</namespace_type_uris>");	
+		 }
 		}
 	 }	
 
@@ -107,6 +110,7 @@
 	  }	
  }catch(Exception e) {
 	Log.severe(e.getMessage());	
+//	e.getMessage();	
 }
 
 }	
@@ -142,7 +146,7 @@
 		
  }catch(Exception e) {
 	 Log.severe(e.getMessage());
-	
+//	e.getMessage();		
   }
 
 	}
@@ -169,6 +173,9 @@
 	
 	public static void startServiceXml(){
 		
+		Report.doBuild("");
+		Report.doBuild("XMLs of the deleted services:");
+		Report.doBuild("");
 		Report.doBuild("<?xml version = '1.0'?>");
 		}		
 }




More information about the MOBY-guts mailing list