[MOBY-guts] biomoby commit

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


nopushneva
Thu Apr 14 12:14:21 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-serv12776

Modified Files:
	Communicator.java ServiceDescrParser.java DataMngr.java 
	Main.java 
Log Message:
recent version

moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier Communicator.java,1.2,1.3 ServiceDescrParser.java,1.2,1.3 DataMngr.java,1.2,1.3 Main.java,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Communicator.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/verifier/Communicator.java	2005/04/07 22:32:12	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Communicator.java	2005/04/14 16:14:21	1.3
@@ -1,24 +1,22 @@
-package org.biomoby.registry.rdfagent.verifier;
 
-import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.Date;
-import java.util.Properties;
+package org.biomoby.registry.rdfagent.verifier;
 
+import com.hp.hpl.jena.rdf.model.*;
+import org.biomoby.registry.rdfagent.util.*;
+import javax.mail.Transport;
 import javax.mail.Message;
-import javax.mail.MessagingException;
 import javax.mail.Session;
-import javax.mail.Transport;
+import javax.mail.MessagingException;
 import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
-
-import org.biomoby.registry.rdfagent.util.Constants;
-import org.biomoby.registry.rdfagent.util.Log;
-import org.biomoby.registry.rdfagent.util.Report;
-
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.ModelFactory;
+import javax.activation.*;
+import java.util.Date; 
+import java.net.*;
+import java.io.*;
+import java.util.Properties;
+import com.hp.hpl.jena.vocabulary.*;
+import org.biomoby.registry.rdfagent.vocabulary.*;
+import java.util.Hashtable;
 /**
  * @author Nina Opushneva
  *
@@ -40,44 +38,54 @@
          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{ 
+
+             	try{             		
 					model.read(huc.getInputStream(),"");         	
-             	}catch(Exception e){
-             		Log.severe("Failed : "+e);
-             	}
+             	}catch(RDFException e){
+            		Log.severe("Failed : "+e);
+            		Report.add("Error 1: "+e);
+//                    e.getMessage();	
+             	}catch(IOException e){
+				  Log.severe("Failed : "+e);
+				  Report.add("Error 3: "+e);
+//				  e.getMessage();	
+			}
                                 
              }
              else {
-
-
 				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){
-					Log.warning("The parameter to this message gives a specification of charging schemes acceptable.");
+					Report.add("The parameter to this message gives a specification of charging schemes acceptable.");
 				}
 				else if (code == 403){
-					Log.warning("The request is for something forbidden. Authorization will not help.");
+					Report.add("The request is for something forbidden. Authorization will not help.");
                     mes1 = "The request is for something forbidden.";
 				}
 				else if (code == 404){
-					Log.warning("The server has not found anything matching the URI given");
+					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 == 500){
-					Log.warning(" Internal Error");
+					Report.add(" Internal Error");
                     mes1 = " Internal Error";
 				}
              	int num  = DataMngr.getServErrorNum(signURL,code);
@@ -89,16 +97,11 @@
                        
                         String servList = DataMngr.getServListByURL(signURL);
 						String s[] = servList.split(",");
-						Report.doWrite("THE CONNECT TO   < "+signURL+" >  WAS REFUSED WITH HTTP CODE "+code+" THREE TIMES IN ROW. ");
-						Report.doWrite("THE SERVICES LOCATED AT  < "+signURL+" >  WILL BE DEREGISTERED FROM mobycentral REGISTRY.");
+						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;
-                   	    if (Constants.MB_MAIL_SERVER != null){
-			              String to = DataMngr.getContactEmail(signURL);
-			              Communicator.sendMail(to,Constants.SP_SUBJECT,msg,Constants.MB_FROM); // send message to the service provider - that service was deregistered
-                          Report.doWrite("The message have been sent to "+to);
-		               }
 
 						Report.doWrite("DELETED SERVICES :");
                         for (int i = s.length - 1; i >=0; i --) {							                           
@@ -106,27 +109,23 @@
                         } 
                         DataMngr.delServiceSetByURL(signURL); 
                         DataMngr.delServErrors(signURL);
-            			Log.warning("THE CONNECT TO   < "+signURL+" >  WAS REFUSED WITH HTTP CODE "+code+" THREE TIMES IN ROW. ");
-                        Log.warning("THE SERVICES LOCATED AT  < "+signURL+" >  WILL BE DEREGISTERED FROM mobycentral REGISTRY");
+            			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);
-             	}
-
-                  String msg = Constants.SP_ERR_MSG_CON +" "+ code+". "+mes1;
-                  	if (Constants.MB_MAIL_SERVER != null){
-			            String to = DataMngr.getContactEmail(signURL);
-			            Communicator.sendMail(to,Constants.SP_SUBJECT,msg,Constants.MB_FROM); // send message to the service provider - that service was deregistered
-                        Report.doWrite("The message have been sent to "+to);
-		           }
+             	}	           
+		
              }
 
               huc.disconnect();
         }
         catch (IOException e) {        	
-			Log.severe(e.getMessage());
+			Log.severe("Failed : "+e);
+			Report.add("Error 2: "+e);
+//			e.getMessage();	
         }
 
          return model;
@@ -136,7 +135,7 @@
 /** 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 the model)
+	* (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.
@@ -147,9 +146,6 @@
 	
 	public static void sendMail(String to,String subj,String msgStr,String from){
 
-//        String from = null;
-//        String host = null;
-
         try {
      
 	        Properties prop = new Properties();
@@ -166,11 +162,78 @@
               transport.connect(Constants.MB_MAIL_SERVER,Constants.MB_MAIL_USER,Constants.MB_MAIL_PSWD);
             }
             Transport.send(msg);
-            Report.doWrite("THE MESSAGE WAS SENT TO "+to);
+            Report.doWrite("The message have been sent to "+to);
         } catch (MessagingException e) {
-			Log.severe(e.getMessage()+" sendmail"); 
+//			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;
+	  }
+
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.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/verifier/ServiceDescrParser.java	2005/04/07 22:32:12	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java	2005/04/14 16:14:21	1.3
@@ -1,646 +1,782 @@
-package org.biomoby.registry.rdfagent.verifier;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.biomoby.registry.rdfagent.util.Constants;
-import org.biomoby.registry.rdfagent.util.Log;
-import org.biomoby.registry.rdfagent.util.Report;
-import org.biomoby.registry.rdfagent.util.XMLBuilder;
-import org.biomoby.registry.rdfagent.vocabulary.MP;
-
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.NodeIterator;
-import com.hp.hpl.jena.rdf.model.Property;
-import com.hp.hpl.jena.rdf.model.ResIterator;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.rdf.model.Statement;
-import com.hp.hpl.jena.rdf.model.StmtIterator;
-import com.hp.hpl.jena.vocabulary.DC;
-import com.hp.hpl.jena.vocabulary.RDF;
-
-/**
- * @author Nina Opushneva
- *
- *  The ServiceDescrParser is a  software component for processing RDF data.
- *  One or more RDF documents can be loaded into the parser and then the parser
- *  browses the input stream and extracts data for to compare with data in database
- */
-public class ServiceDescrParser {
-
-	Model servDescrMd;
-	int in = 0;
-	int out = 0;
-	int bag = 0;
-	int n = 0;
-    int[] ver = {0,0,0,0,0,0,0,0};	        
-
-	ServiceDescrParser(Model serviceDescrMd){
-
-		this.servDescrMd = serviceDescrMd;
-	}
-
-/** get a provider's RDF file by signatureURL,
- *  and check if every of service RDF is valid MOBY
-		* @param signURL - the URL of resource (signatureURL)
-		* @param servNames - list of services which have registered with signURL
-		* 
-		*/
-
-   public void getValidRDF(String servNames,String signURL){
-   	String res = "";
-   	int amount = 0;
-   	int validMoby = 0;
-   	int servError = 0;
-	Vector resources = new Vector();     // the list of services at given URL (including new services)
-	String auth_URI = "";
-   	String servName = "";
-   	Vector deletedServ =  new Vector();  // the list of deleted services from database
-   	
-   	
- // get the set of RDF with the same signatureURL
-    
-   	ResIterator iter = servDescrMd.listSubjectsWithProperty(DC.title);
-   	while (iter.hasNext()){
-   		String resource = iter.next().toString();		
-		Hashtable servSign = new Hashtable();
-		amount += 1;
-
-		servSign = getServSignature(resource);
-		           
-		if(!servSign.isEmpty()){	                // a valid MOBY RDF
-			servName  = servSign.get("servicename").toString();
-			auth_URI = servSign.get("authURI").toString();			
-		    resources.addElement(servName);                            
-
-			Hashtable servInp = new Hashtable();			
-			servInp = getInput(resource) ;              
-		    Hashtable servOut = new Hashtable();		    
-			servOut = getOutput(resource) ;
-
-            for (int i = 0; i < ver.length; i++) {       // a clearance of the array ver[]
-                ver[i] = 0;
-
-            }
-            if (servInp.containsValue("error") | servOut.containsValue("error")){
-                servError +=1;
-                String msg = "A bad Input or Output structure for the service <"+ servName+">. ";
-                String msg1 = "The service have not processed";
-                Report.doWrite(msg+msg1);
-            }else{
-               DataMngr.processService(servSign,servInp,servOut,servName,auth_URI,signURL);
-            }
-		}else{
-           validMoby += 1;	         // a not valid MOBY RDF
-        }
-   	}
- 	
-	String[] result = servNames.split(",");	
-
-Report.doWrite("");
-Report.doWrite("Expected  services for given URL "+result.length);
-Report.doWrite("In fact   = "+resources.size());		
-	for (int j=0;j<result.length;j++){
-		
-		res = "";
-		for (int i=0; i<resources.size(); i++) {
-			 String s = (String) resources.elementAt(i);		 
-			 if (result[j].equals(s)){			 					
-				 res = "ok";				 
-				 break;
-			}	 
-		}
-	
-		if (res.equals("")){
-			servName = result[j];
-						
-			XMLBuilder.buildServiceXml(servName,signURL);					 			 	
-			DataMngr.delServByNameAndUrl(servName,signURL);
-			deletedServ.addElement(servName);
-			String msg = "The service < "+ servName+" > was not found in the RDF file. The service was deregistered from MOBYCENTRAL Registry" ;
-			Report.doWrite(msg );
-System.out.println("server = "+Constants.MB_MAIL_SERVER);			
-             if (Constants.MB_MAIL_SERVER != null){
-			      String to = DataMngr.getContactEmail(signURL);
-			      Communicator.sendMail(to,Constants.SP_SUBJECT,msg,Constants.MB_FROM); // send message to the service provider - that service was deregistered
-                  Report.doWrite("The message have been sent to "+to);
-		    }
-	    }						 	
- 	}	             	  	      		
-   	int del = deletedServ.size();
-   	if (del > 0){
-   		Report.doWrite("DELETED SERVICES: ");
-		Iterator i = deletedServ.iterator();
-		int n1=1;
-	    while (i.hasNext()){
-			String delServ = i.next().toString();
-			Report.doWrite(n1+". "+delServ);
-			n1+=1;
-	    }
-		   
-   	}
-
-    if (servError >= validMoby){
-	  Report.doWrite("notValidMoby services or with a bad structure = "+servError);
-    } else{
-      Report.doWrite("notValidMoby services or with a bad structure = "+validMoby);
-    }
-	Report.doWrite("=======================================================================================");
-//   	Log.info("Discovered services = "+amount);
-//	Log.info("notValidMoby services  = "+validMoby);
-    Log.info("=======================================================================");
-   }
-
-
- /** get service Signature data for the service
-	   * @param resource - the URL of resource + serviceName+authURI
-	   * @return Hashtable represented by a pair: service signature descriptor and value 
-	   */
-
-	public Hashtable getServSignature(String resource){
-        
-        Hashtable sign = new Hashtable();
-
-	    Resource si = servDescrMd.getResource(resource);
-		
-	    Report.doWrite("----------------------------------------------------------------------------------------");
-		n +=1;                                    // the number of RDF at the signatureURL
-		Log.info("RDF "+n+" : "+ si);
-		Report.doWrite("RDF "+n+" : "+ si);	  
-		StmtIterator signNum = si.listProperties();
-
-			while (signNum.hasNext()) {
-				Statement stmtSign = signNum.nextStatement();
-				String signPred = stmtSign.getPredicate().toString().trim();
-				String signNode = stmtSign.getObject().toString();
-			        String[] rezNode = signNode.split(":http:");
-			        signNode = rezNode[0];
-		        
-					String[] result = signPred.split("#");
-			        int i = (result.length)-1;
-			        if (i == 0){
-			      	  String[] res = signPred.split("/");
-				      int j = (res.length)-1;
-				      String name = getFieldName(res[j]);				   				      
-				      sign.put(name,signNode);				     
-			        }
-			        else {
-				      if (result[i].equals("input") | result[i].equals("consumes")){
-				  	     in = 1;
-				      }
-				      if (result[i].equals("output") | result[i].equals("produces")){
-					     out = 1;                          
-				      }
-					  String name = getFieldName(result[i]);
-					  sign.put(name,signNode);
-				   }
-		}
-
-                     for (int vn=0; vn<ver.length; vn++){     // an array of the basic predicates for service signature
-
-                     	if (ver[vn] != 1){
-                     		Log.info("THE RDF IS NOT VALID MOBY RDF - absent "+ ver[vn]);
-                            Report.doWrite("THE RDF IS NOT VALID MOBY RDF: one or more MOBY descriptors are absent");
-                     		sign.clear();
-                            break;
-                        }else{
-                      	
-                     	   if (in == 0 && out == 0){
-							Report.doWrite("THE RDF IS NOT VALID MOBY RDF: Input and Output are absent ");
-							Log.info("THE RDF IS NOT VALID MOBY RDF - Consumes and Produces are absent");
-							sign.clear();
-                     	   }else{
-							  Enumeration num = sign.keys();			  
-                                
-							  }
-                     	    }
-                         }	                					   		
-        return sign;
-    }
-
-	/** get set of Inputs for service (Simple, Collection, and Secondary)
-	   * @param resource - the URL of resource + serviceName+authURI
-	   * @return Hashtable of hashtables represented by a pair: 
-	   * a name of the input = hashtable for this input 
-	   * hashtable for input is represented by a Input descriptor and value.
-	   * 
-	   */
-	
-
-	public Hashtable getInput(String resource){
-		int bagin = 0;
-		int sin = 1;
-		int cin = 1;
-		int sec = 1;
-		String simple = "ok";
-        String collection = "ok";
-        String secondary = "ok";
-
-		Hashtable input = new Hashtable();
-		
-		
-	   Resource si = servDescrMd.getResource(resource);
-		NodeIterator ob2iter = servDescrMd.listObjectsOfProperty(si,MP.consumes);
-		while (ob2iter.hasNext()) {
-			
-			StmtIterator p23iter = ((Resource) ob2iter.next()).listProperties();
-			while (p23iter.hasNext()) {
-				Hashtable siminp = new Hashtable();             // a simple input        
-				Hashtable colinp = new Hashtable();             // a collection input
-				Hashtable secinp = new Hashtable();             // a secondary input
-				StringBuffer sumsns = new StringBuffer();       // the row of namespaces
-				StringBuffer sumen = new StringBuffer();        // the row of enum
-				
-				Statement l3iter = p23iter.nextStatement();
-				Property l3Pred = l3iter.getPredicate();
-                 Node l3Node = l3iter.getObject().asNode();
-
-				if (l3Pred.equals(RDF.type)   ){
-						bagin = 1;
-				}
-                else if (l3Pred.equals(MP.SimpleArticle)){
-					Resource l3Res = l3iter.getResource();            
-					StmtIterator p34iter = l3Res.listProperties();
-					while (p34iter.hasNext()) {							
-					   Statement l4iter = p34iter.nextStatement();				  	   
-					   String l4Pred1 = l4iter.getPredicate().toString();
-						String l4Node1 = l4iter.getObject().toString();														                             
-						String[] result = l4Pred1.split("#");
-						int i = (result.length)-1;
-			
-						String name = getInpOutName(result[i]);
-                        if (name.equals("")){
-                          Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Simple input <"+result[i]+">");
-                          simple = "error";
-                           break;
-                        }
-						String[] rezNode1 = l4iter.getObject().toString().split(":http:");
-						String l4Nodestr = rezNode1[0];
-						if (name.equals("namespace_type_uris")){
-						 siminp.remove("namespace_type_uris");
-						 sumsns.append(l4Nodestr+",");
-						 siminp.put(name,sumsns.toString());								                             
-						}else{
-						  siminp.put(name,l4Nodestr);								   
-						}
-                    }
-					if (siminp.isEmpty()){
-					}else{						
-					   input.put("siminp"+sin,siminp);   // to add Simple to Input
-					   sin+=1;					   
-					   Enumeration num = siminp.keys();
-					  
-					   Report.doWrite("Simple input "+ (sin-1));
-//					   Log.info("Simple input "+ (sin-1));				   						  
-				   } 
-                }
-				else if (l3Pred.equals(MP.CollectionArticle)){
-					Resource l3Res = l3iter.getResource();
-					if (l3Res.hasProperty(RDF.type,RDF.Bag) && l3Res.hasProperty(RDF.li(1))){
-						StmtIterator p34iter = l3Res.listProperties();
-						if (l3Res.hasProperty(MP.article_name)){
-				 		  String col_artName = l3Res.getProperty(MP.article_name).getObject().toString();
-						  String[] rezNode = col_artName.split(":http:");
-						  col_artName = rezNode[0];
-						  colinp.put("col_articleName",col_artName);						
-					    }	
-						 while (p34iter.hasNext()) {							
-						    Statement l4iter = p34iter.nextStatement();
-						    Property l4Pred = l4iter.getPredicate();
-							Node l4Node = l4iter.getObject().asNode();
-                               							 
-							if (l4Node.isBlank()){							   		
-								Resource l4Res = l4iter.getResource();            
-								StmtIterator p45iter = l4Res.listProperties();
-								if(p45iter.hasNext()) {																		
-									StringBuffer sumns = new StringBuffer();
-									while (p45iter.hasNext()) {
-										Statement l5iter = p45iter.nextStatement();
-										String l5Pred = l5iter.getPredicate().toString();
-										Node l5Node = l5iter.getObject().asNode();
-										String[] result = l5Pred.split("#");
-										int i = (result.length)-1;				
-										String name = getInpOutName(result[i]);
-                                         if (name.equals("")){
-                                            Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Collection input <"+result[i]+">");
-                                            String Collection = "error";
-                                            break;
-                                         }
-										String[] rezNode = l5iter.getObject().toString().split(":http:");
-										String l5Nodestr = rezNode[0];										
-										if (name.equals("namespace_type_uris")){
-											sumns.append(l5Node+",");
-										}
-										else{
-											 colinp.put(name,l5Node);
-										}
-									}														
-										input.put("colinp"+cin,colinp);
-										cin+=1;
-										Enumeration num = colinp.keys();
-									    Report.doWrite("Collection input "+(cin-1));
-//										Log.info("Collection input "+(cin-1));
-
-							   }
-					   }
-					    
-					}    			
-					}else{
-                        collection = "error";
-						Report.doWrite("BAD STRUCTURE: The Collection input isn't 'Bag' type or have not members");
-						System.out.println("The structure is not correct");	
-					}
-				}
-                else if (l3Pred.equals(MP.SecondaryArticle)){
-					Resource l3Res = l3iter.getResource();            
-					StmtIterator p34iter = l3Res.listProperties();
-					while (p34iter.hasNext()) {							
-					   Statement l4iter = p34iter.nextStatement();
-					   String l4Pred1 = l4iter.getPredicate().toString();
-					   String l4Node1 = l4iter.getObject().toString();														                             
-					   String[] result = l4Pred1.split("#");
-					   int i = (result.length)-1;			
-					   String name = getSecondaryName(result[i]);
-                       if (name.equals("")){
-                          Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Secondary input <"+result[i]+">");
-                           secondary = "error";
-                            break;
-                       }
-					   String[] rezNode1 = l4iter.getObject().toString().split(":http:");
-					   String l4Nodestr = rezNode1[0];	
-					 
-					   if (name.equals("enum")){
-	                     secinp.remove("enum");
-	                     sumen.append(l4Nodestr+",");
-	                     secinp.put(name,sumen.toString()); 
-                                
-	                  }
-	                  else{							
-	                    secinp.put(name,l4Nodestr);  								
-                      }
-				  }					  
-              
-			  if (secinp.isEmpty()){						
-			  }else{
-				  input.put("secinp"+sec,secinp);								// to add Secondary to Input					
-				  sec+=1;
-				  Enumeration num = secinp.keys();
-				  Report.doWrite("Secondary input "+ (sec-1));
-//				  Log.info("Secondary input "+ (sec-1));
-			  }			    					 
-       }     
-
-		  }
-		}
-       if (simple.equals("error") | collection.equals("error") | secondary.equals("error")){
-         input.put("input","error");
-       }
-// System.out.println("input= "+input);
-		return input;
-	}
-
-/** get set of Outputs for service (Simple and Collection)
-	   * @param resource - the URL of resource + serviceName+authURI
-	   * @return Hashtable of hashtables represented by a pair: 
-	   * a name of the output = hashtable for this output 
-	   * hashtable for output is represented by a Output descriptor and value.
-	   * 
-	   */
-
-	public Hashtable getOutput(String resource){
-		int bagout = 0;
-		int so = 1;
-		int co = 1;
-        String simple = "ok";
-        String collection = "ok";
-
-		Hashtable output = new Hashtable();
-
-	   Resource si = servDescrMd.getResource(resource);
-
-	NodeIterator ob2iter = servDescrMd.listObjectsOfProperty(si, MP.produces);
-			while (ob2iter.hasNext()) {
-				StmtIterator p23iter = ((Resource) ob2iter.next()).listProperties();
-				while (p23iter.hasNext()) {
-					Statement l3iter = p23iter.nextStatement();
-					Property l3Pred = l3iter.getPredicate();
-					Node l3Node = l3iter.getObject().asNode();
-
-					Hashtable simout = new Hashtable();
-					Hashtable colout = new Hashtable();
-					StringBuffer simpns = new StringBuffer();
-					StringBuffer colons = new StringBuffer();
-
-					if (l3Pred.equals(RDF.type)   ){
-							bagout = 1;
-					}
-
-                else if (l3Pred.equals(MP.SimpleArticle)){
-					Resource l3Res = l3iter.getResource();
-					StmtIterator p34iter = l3Res.listProperties();
-					while (p34iter.hasNext()) {
-					   Statement l4iter = p34iter.nextStatement();
-					   String l4Pred1 = l4iter.getPredicate().toString();
-						String l4Node1 = l4iter.getObject().toString();
-						String[] result = l4Pred1.split("#");
-						int i = (result.length)-1;
-
-						String name = getInpOutName(result[i]);
-                        if (name.equals("")){
-                          Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Simple output <"+result[i]+">");
-                          simple = "error";
-                           break;
-                        }
-						String[] rezNode1 = l4iter.getObject().toString().split(":http:");
-						String l4Nodestr = rezNode1[0];
-						if (name.equals("namespace_type_uris")){
-						 simout.remove("namespace_type_uris");
-						 simpns.append(l4Nodestr+",");
-						 simout.put(name,simpns.toString());
-						}else{
-						  simout.put(name,l4Nodestr);
-						}
-                    }
-					if (simout.isEmpty()){
-					}else{
-					   output.put("simout"+so,simout);   // to add Simple to Input
-					   so+=1;
-					   Enumeration num = simout.keys();
-
-					   Report.doWrite("Simple output "+ (so-1));
-//					   Log.info("Simple output "+ (so-1));
-				   }
-                }
-				else if (l3Pred.equals(MP.CollectionArticle)){
-					Resource l3Res = l3iter.getResource();
-					if (l3Res.hasProperty(RDF.type,RDF.Bag) && l3Res.hasProperty(RDF.li(1))){
-						StmtIterator p34iter = l3Res.listProperties();
-						if (l3Res.hasProperty(MP.article_name)){
-				 		  String col_artName = l3Res.getProperty(MP.article_name).getObject().toString();
-						  String[] rezNode = col_artName.split(":http:");
-						  col_artName = rezNode[0];
-						  colout.put("col_articleName",col_artName);
-					    }
-						 while (p34iter.hasNext()) {
-						    Statement l4iter = p34iter.nextStatement();
-						    Property l4Pred = l4iter.getPredicate();
-							Node l4Node = l4iter.getObject().asNode();
-
-							if (l4Node.isBlank()){
-								Resource l4Res = l4iter.getResource();
-								StmtIterator p45iter = l4Res.listProperties();
-								if(p45iter.hasNext()) {
-									StringBuffer sumns = new StringBuffer();
-									while (p45iter.hasNext()) {
-										Statement l5iter = p45iter.nextStatement();
-										String l5Pred = l5iter.getPredicate().toString();
-										Node l5Node = l5iter.getObject().asNode();
-										String[] result = l5Pred.split("#");
-										int i = (result.length)-1;
-										String name = getInpOutName(result[i]);
-                                         if (name.equals("")){
-                                            Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Collection output <"+result[i]+">");
-                                            String Collection = "error";
-                                            break;
-                                         }
-										String[] rezNode = l5iter.getObject().toString().split(":http:");
-										String l5Nodestr = rezNode[0];
-										if (name.equals("namespace_type_uris")){
-											sumns.append(l5Node+",");
-										}
-										else{
-											 colout.put(name,l5Node);
-										}
-									}
-										output.put("colout"+co,colout);
-										co+=1;
-										Enumeration num = colout.keys();
-									    Report.doWrite("Collection output "+(co-1));
-//										Log.info("Collection output "+(co-1));
-
-							   }
-					   }
-
-					}
-					}else{
-                        collection = "error";
-						Report.doWrite("BAD STRUCTURE: The Collection output isn't 'Bag' type or have not members");
-						System.out.println("The structure is not correct");
-					}
-				}
-		  }
-		}
-       if (simple.equals("error") | collection.equals("error")){
-         output.put("output","error");
-       }
-
-		return output;
-	}
-
-
-/** mapping RDF data to the database data
-		   * @param name - the name of predicate in the RDF of service
-		   * @return String field name in database corresponding with this predicate 
-		   * 
-		   */
-	
-
-public String getFieldName(String name){
-	String res = "";
-
-	if (name.equals("publisher") | name.equals("authURI")){
-		ver[0] = 1;
-		res = "authURI";
-	}
-	else if (name.equals("category")){
-		ver[1] = 1;
-		res = "category";
-	}
-	else if (name.equals("creator") | name.equals("contactEmail")){
-		ver[2] = 1;
-		res = "contact_email";
-	}
-	else if (name.equals("identifier") | name.equals("URL")){
-		ver[3] = 1;
-		res = "URL";
-	}
-	else if (name.equals("performs_task") | name.equals("serviceType")){
-		ver[4] = 1;
-		res = "service_type_uri";
-	}
-	else if (name.equals("title") | name.equals("serviceName")){
-		ver[5] = 1;
-		res = "servicename";		
-	}
-	else if (name.equals("description") | name.equals("comment")){
-		ver[6] = 1;
-		res = "description";
-	}	
-	else if (name.equals("authoritative") | name.equals("coverage")){
-		ver[7] = 1;
-		res = "authoritative";	
-	}	
-	else if (name.equals("signatureURL") ){			
-		res = "signatureURL";	
-		}			 		 
-
- return res;
-}
-
-/** mapping RDF input/output data to the database data
-		   * @param name - the name of predicate in the RDF of service
-		   * @return String field name in database corresponding with this predicate 
-		   * 
-		   */
-
-public String getInpOutName(String name){
-	String res = "";
-	    if (name.equals("article_name")){			
-			res = "articleName";
-		}
-
-		else if (name.equals("object_type")){
-			res = "object_type_uri";
-		}		
-	    else if (name.equals("namespace_type")){
-			res = "namespace_type_uris";
-		}
-
-	return res;
-}
-
-/** mapping RDF Secondary data to the database data
-		   * @param name - the name of predicate in the RDF of service
-		   * @return String field name in database corresponding with this predicate 
-		   * 
-		   */
-
-public String getSecondaryName(String name){
-	String res = "";
-		
-		if (name.equals("article_name")){
-			res = "article_name";
-		}	 
-			
-		if (name.equals("default_value")){			
-			res = "default";
-		}
-		if (name.equals("datatype")){			
-			res = "datatype";
-		}
-		if (name.equals("max")){			
-		  res = "max";
-		}
-		if (name.equals("min")){			
-			  res = "min";
-		}
-		if (name.equals("enum")){			
-			  res = "enum";
-		}
-	
-	return res;
-}	
+package org.biomoby.registry.rdfagent.verifier;
+
+import org.biomoby.registry.rdfagent.util.*;
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.rdf.model.*;
+import com.hp.hpl.jena.vocabulary.*;
+import org.biomoby.registry.rdfagent.vocabulary.*;
+import java.io.PrintWriter;
+import java.util.StringTokenizer;
+import java.util.*;
+
+/**
+ * @author Nina Opushneva
+ *
+ *  The ServiceDescrParser is a  software component for processing RDF data.
+ *  One or more RDF documents can be loaded into the parser and then the parser
+ *  browses the input stream and extracts data for to compare with data in database
+ */
+public class ServiceDescrParser {
+
+	Model servDescrMd;
+	
+	int bag = 0;
+	int n = 0;
+    int[] ver = {0,0,0,0,0,0,0,0};	        
+
+	ServiceDescrParser(Model serviceDescrMd){
+
+		this.servDescrMd = serviceDescrMd;
+	}
+
+/** get a provider's RDF file by signatureURL,
+ *  and check if every of service RDF is valid MOBY
+		* @param signURL - the URL of resource (signatureURL)
+		* @param servNames - list of services which have registered with signURL
+		* 
+		*/
+
+   public void getValidRDF(String servNames,String signURL){
+   	String res = "";
+   	int amount = 0;
+   	int validMoby = 0;
+   	int servError = 0;
+	Vector resources = new Vector();     // the list of services at given URL (including new services)
+	String auth_URI = "";
+   	String servName = "";
+   	Vector deletedServ =  new Vector();  // the list of deleted services from database
+   	
+   	
+ // get the set of RDF with the same signatureURL
+    
+   	ResIterator iter = servDescrMd.listSubjectsWithProperty(DC.title);
+   	while (iter.hasNext()){
+   		String resource = iter.next().toString();		
+		Hashtable servSign = new Hashtable();
+		amount += 1;
+
+		servSign = getServSignature(resource);
+		           
+		if(!servSign.isEmpty()){	                // a valid MOBY RDF
+			servName  = servSign.get("servicename").toString();
+			auth_URI = servSign.get("authURI").toString();			
+		    resources.addElement(servName);                            
+
+			Hashtable servInp = new Hashtable();			
+			servInp = getInput(resource) ;              
+		    Hashtable servOut = new Hashtable();		    
+			servOut = getOutput(resource) ;
+
+            for (int i = 0; i < ver.length; i++) {       // a clearance of the array ver[]
+                ver[i] = 0;
+
+            }
+            if (servInp.containsValue("error") | servOut.containsValue("error")){
+                servError +=1;
+                String msg = "A bad Input or Output structure for the service <"+ servName+">. ";
+                String msg1 = "The service have not processed";
+                Report.doWrite(msg+msg1);
+            }else{
+               DataMngr.processService(servSign,servInp,servOut,servName,auth_URI,signURL);
+            }
+		}else{
+           validMoby += 1;	         // a not valid MOBY RDF
+        }
+		
+   	}
+ 	
+	String[] result = servNames.split(",");
+	
+	
+  Report.doWrite("");
+  Report.add("----------------------------------------------------------------------------------------");
+  Report.add(" ");
+  Report.doWrite("Expected  services for given URL "+result.length);
+  Report.add("Expected  services for given URL "+result.length);
+
+  Report.doWrite("In fact   = "+amount);
+  Report.add("In fact   = "+amount);
+  Report.add("notValidMoby services or with a bad structure = "+(servError+validMoby));
+  Report.add(" ");
+  			
+	for (int j=0;j<result.length;j++){		
+		res = "";
+		for (int i=0; i<resources.size(); i++) {
+			 String s = (String) resources.elementAt(i);		 
+			 if (result[j].equals(s)){			 					
+				 res = "ok";				 
+				 break;
+			}	 
+		}
+	
+		if (res.equals("")){
+			servName = result[j];
+			if (deletedServ.size()==0){
+				XMLBuilder.startServiceXml();
+			}			
+			XMLBuilder.buildServiceXml(servName,signURL);					 			 	
+			DataMngr.delServByNameAndUrl(servName,signURL);			
+			deletedServ.addElement(servName);
+			String msg = "The service < "+ servName+" > was not found in the RDF file. The service was deregistered from MOBYCENTRAL Registry" ;
+			Report.doWrite(msg );
+			Report.add(msg );
+		
+/*             if (Constants.MB_MAIL_SERVER != null | Constants.MB_MAIL_SERVER.equals("") ){
+			      String to = DataMngr.getContactEmail(signURL);
+			      Communicator.sendMail(to,Constants.SP_SUBJECT,msg,Constants.MB_FROM); // send message to the service provider - that service was deregistered
+ 
+		    }*/
+	    }						 	
+ 	}	             	  	      		
+   	int del = deletedServ.size();
+   	if (del > 0){
+   		Report.doWrite("DELETED SERVICES: ");
+   		Report.add(" ");
+   		Report.add("DELETED SERVICES: ");
+		Iterator i = deletedServ.iterator();
+		int n=1;
+	    while (i.hasNext()){
+			String delServ = i.next().toString();
+			Report.doWrite(n+". "+delServ);
+			Report.add(n+". "+delServ);
+			n+=1;
+	    }
+		   
+   	}
+	Report.doWrite("notValidMoby services or with a bad structure = "+(servError+validMoby));
+//	Report.add("notValidMoby services or with a bad structure = "+(servError+validMoby));
+	Report.doWrite("=======================================================================================");
+
+  Log.info("=======================================================================");
+   }
+
+
+ /** get service Signature data for the service
+	   * @param resource - the URL of resource + serviceName+authURI
+	   * @return Hashtable represented by a pair: service signature descriptor and value 
+	   */
+
+	public Hashtable getServSignature(String resource){
+        
+        Hashtable sign = new Hashtable();
+
+	    Resource si = servDescrMd.getResource(resource);
+		
+	    Report.doWrite("----------------------------------------------------------------------------------------");
+		Report.add("----------------------------------------------------------------------------------------");
+		n +=1;                                    // the number of RDF at the signatureURL
+		Log.info("RDF "+n+" : "+ si);
+		Report.doWrite("RDF "+n+" : "+ si);			
+        Report.add("RDF "+n+" : "+ si);		
+		
+		int in = 0;
+		int out = 0;  
+		StmtIterator signNum = si.listProperties();
+
+			while (signNum.hasNext()) {
+				Statement stmtSign = signNum.nextStatement();				
+				String signPred = stmtSign.getPredicate().toString().trim();
+				String signNode = stmtSign.getObject().toString();              
+				
+			        String[] rezNode = signNode.split(":http:");
+			        int k = (rezNode.length)-1;
+			        if (k == 0){
+						String[] rezNode1 = signNode.split("~");
+						signNode = rezNode1[0];
+			        }else{
+						signNode = rezNode[0];
+			        }
+		        
+					String[] result = signPred.split("#");
+			        int i = (result.length)-1;
+			        if (i == 0){
+			      	  String[] res = signPred.split("/");
+				      int j = (res.length)-1;
+				      String name = getFieldName(res[j]);			      
+				      sign.put(name,signNode);				     
+			        }
+			        else {
+				      if (result[i].equals("input") | result[i].equals("consumes")){
+				  	     in = 1;
+				      }
+				      if (result[i].equals("output") | result[i].equals("produces")){
+					     out = 1;                          
+				      }
+					  String name = getFieldName(result[i]);
+					  if (name.equals("service_type_uri")){					  	
+						String lsid_node = switchURItoLSID(signNode);
+						  sign.put(name,lsid_node);					  	
+					  }else{
+						sign.put(name,signNode);
+					  }
+ 	
+					  
+				   }
+		}
+
+                     for (int vn=0; vn<ver.length; vn++){     // an array of the basic predicates for service signature
+
+                     	if (ver[vn] != 1){
+                     		Log.info("THE RDF IS NOT VALID MOBY RDF - absent "+ ver[vn]);
+                            Report.doWrite("THE RDF IS NOT VALID MOBY RDF: one or more MOBY descriptors are absent");
+							Report.add("THE RDF IS NOT VALID MOBY RDF: one or more MOBY descriptors are absent");
+                     		sign.clear();
+                            break;
+                        }
+                     }	
+                     	   if (in == 0 && out == 0){
+							Report.doWrite("THE RDF IS NOT VALID MOBY RDF: Input and Output are absent ");
+							Report.add("THE RDF IS NOT VALID MOBY RDF: Input and Output are absent ");
+							Log.info("THE RDF IS NOT VALID MOBY RDF - Consumes and Produces are absent");
+							sign.clear();
+                     	   }else{
+							  Enumeration num = sign.keys();			  
+                                
+							  }
+                     	    
+                                        					   		
+        return sign;
+    }
+
+	/** get set of Inputs for service (Simple, Collection, and Secondary)
+	   * @param resource - the URL of resource + serviceName+authURI
+	   * @return Hashtable of hashtables represented by a pair: 
+	   * a name of the input = hashtable for this input 
+	   * hashtable for input is represented by a Input descriptor and value.
+	   * 
+	   */
+	
+
+	public Hashtable getInput(String resource){
+		int bagin = 0;
+		int sin = 1;
+		int cin = 1;
+		int sec = 1;
+		String simple = "ok";
+        String collection = "ok";
+        String secondary = "ok";
+
+		Hashtable input = new Hashtable();
+		
+		
+	   Resource si = servDescrMd.getResource(resource);
+      
+        try{
+			Resource consumes = si.getRequiredProperty(MP.consumes).getResource();					
+			StmtIterator p23iter =  consumes.listProperties();       			
+			
+			while (p23iter.hasNext()) {
+				Hashtable siminp = new Hashtable();             // a simple input        
+				Hashtable colinp = new Hashtable();             // a collection input
+				Hashtable secinp = new Hashtable();             // a secondary input
+				StringBuffer sumsns = new StringBuffer();       // the row of namespaces
+				StringBuffer sumen = new StringBuffer();        // the row of enum
+				
+				Statement l3iter = p23iter.nextStatement();
+                Resource l3Res = l3iter.getResource();
+
+                if (l3Res.isAnon()){	               
+       
+                 Object type = l3Res.getRequiredProperty(RDF.type).getObject();
+               
+                if (type.equals(MRes.Simple)){     
+					StmtIterator p34iter = l3Res.listProperties();
+					
+					while (p34iter.hasNext()) {	
+											
+					    Statement l4iter = p34iter.nextStatement();					   					 					   
+					    String l4Pred1 = l4iter.getPredicate().toString();
+						String l4Node1 = l4iter.getObject().toString();	
+						String[] result = l4Pred1.split("#");
+						int i = (result.length)-1;
+			
+						String name = getInpOutName(result[i]);
+                        if (name.equals("")){
+                          Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Simple input <"+result[i]+">");
+						  Report.add("BAD STRUCTURE: Unknown name of predicate for Simple input <"+result[i]+">");
+                          simple = "error";
+                          continue;
+                        }
+                        if (name.equals("type")){
+                        	continue;
+                        }	
+						String[] rezNode1 = l4iter.getObject().toString().split(":http:");
+						String l4Nodestr = rezNode1[0];
+						if (name.equals("namespace_type_uris")){
+						   siminp.remove("namespace_type_uris");
+						   String lsid_nsp = switchURItoLSID(l4Nodestr);
+						  if (sumsns.length()==0){
+						    	sumsns.append(lsid_nsp);
+						  }else{
+						    	sumsns.append(","+lsid_nsp);
+						   }
+						 
+						  siminp.put(name,sumsns.toString());	
+					   }
+						else if (name.equals("object_type_uri")){						
+							String lsid_nsp = switchURItoLSID(l4Nodestr);
+							siminp.put(name,lsid_nsp);
+						}
+						else{						
+						  siminp.put(name,l4Nodestr);								   
+						}
+                    }
+					if (siminp.isEmpty()){
+					}else{						
+					   input.put("siminp"+sin,siminp);   // to add Simple to Input
+					   sin+=1;					   
+					   Enumeration num = siminp.keys();
+					  
+				}
+         }				
+				else if (type.equals(MRes.Collection) | type.equals(RDF.Bag)){
+//					if (l3Res.hasProperty(RDF.type,RDF.Bag) && l3Res.hasProperty(RDF.li(1))){
+					if (l3Res.hasProperty(RDF.li(1))){
+						StmtIterator p34iter = l3Res.listProperties();
+						if (l3Res.hasProperty(MP.article_name)){
+				 		  String col_artName = l3Res.getProperty(MP.article_name).getObject().toString();
+						  String[] rezNode = col_artName.split(":http:");
+						  col_artName = rezNode[0];
+						  colinp.put("col_articleName",col_artName);						
+					    }	
+						 while (p34iter.hasNext()) {							
+						    Statement l4iter = p34iter.nextStatement();
+						    Property l4Pred = l4iter.getPredicate();
+							Node l4Node = l4iter.getObject().asNode();
+                               							 
+							if (l4Node.isBlank()){							   		
+								Resource l4Res = l4iter.getResource();            
+								StmtIterator p45iter = l4Res.listProperties();
+								if(p45iter.hasNext()) {																		
+									StringBuffer sumns = new StringBuffer();
+									while (p45iter.hasNext()) {
+										Statement l5iter = p45iter.nextStatement();
+										String l5Pred = l5iter.getPredicate().toString();
+										Node l5Node = l5iter.getObject().asNode();
+										String[] result = l5Pred.split("#");
+										int i = (result.length)-1;				
+										String name = getInpOutName(result[i]);
+                                         if (name.equals("")){
+                                            Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Collection input <"+result[i]+">");
+											Report.add("BAD STRUCTURE: Unknown name of predicate for Collection input <"+result[i]+">");
+                                            String Collection = "error";
+                                            break;
+                                         }
+										String[] rezNode = l5iter.getObject().toString().split(":http:");
+										String l5Nodestr = rezNode[0];										
+										if (name.equals("namespace_type_uris")){
+											colinp.remove("namespace_type_uris");
+											String lsid_nsp = switchURItoLSID(l5Node.toString());
+											if (sumns.length()==0){
+												sumns.append(lsid_nsp);
+											}else{
+												sumns.append(","+lsid_nsp);
+											}
+                                            
+											colinp.put(name,sumns.toString());
+//											sumns.append(l5Node+",");
+										}else if (name.equals("object_type_uri")){
+											String lsid_nsp = switchURItoLSID(l5Node.toString());
+											colinp.put(name,lsid_nsp);
+										}
+										else{
+											 colinp.put(name,l5Node);
+										}
+									}														
+										input.put("colinp"+cin,colinp);
+										cin+=1;
+										Enumeration num = colinp.keys();
+							   }
+					   }
+					    
+					}    			
+					}else{
+                        collection = "error";
+						Report.doWrite("BAD STRUCTURE: The Collection input isn't 'Bag' type or have not members");
+						Report.add("BAD STRUCTURE: The Collection input isn't 'Bag' type or have not members");
+	
+					}
+				}
+				if (type.equals(MRes.Secondary)){  
+				           
+					StmtIterator p34iter = l3Res.listProperties();
+					while (p34iter.hasNext()) {							
+					   Statement l4iter = p34iter.nextStatement();
+					   String l4Pred1 = l4iter.getPredicate().toString();
+					   String l4Node1 = l4iter.getObject().toString();					
+					   									                             
+					   String[] result = l4Pred1.split("#");
+					   int i = (result.length)-1;			
+					   String name = getSecondaryName(result[i]);
+					   
+                       if (name.equals("")){
+                          Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Secondary input <"+result[i]+">");
+						  Report.add("BAD STRUCTURE: Unknown name of predicate for Secondary input <"+result[i]+">");
+                           secondary = "error";
+                            break;
+                       }
+                        
+					   String[] rezNode1 = l4iter.getObject().toString().split(":http:");
+					   String l4Nodestr = rezNode1[0];					   						 
+					   if (name.equals("enum")){
+	                     secinp.remove("enum");
+	                     if (sumen.length()==0){
+							sumen.append(l4Nodestr);
+	                     }else{
+							sumen.append(","+l4Nodestr);
+	                     }
+	                     
+	                     secinp.put(name,sumen.toString()); 
+                                
+	                  }
+	                  else{							
+	                    secinp.put(name,l4Nodestr);  								
+                      }
+				  }					  
+              
+			  if (secinp.isEmpty()){						
+			  }else{
+				  input.put("secinp"+sec,secinp);								// to add Secondary to Input					
+				  sec+=1;
+				  Enumeration num = secinp.keys();
+//				  Report.doWrite("Secondary input "+ (sec-1));
+//				  Log.info("Secondary input "+ (sec-1));
+			  }			    					 
+           }     
+         }
+  }
+		
+       if (simple.equals("error") | collection.equals("error") | secondary.equals("error")){
+         input.put("input","error");
+       }	
+	}catch(Exception e){
+		Log.warning("Failed:"+ e);
+	}       
+//        }
+//System.out.println("input= "+input);
+		return input;
+        	
+	}
+
+/** get set of Outputs for service (Simple and Collection)
+	   * @param resource - the URL of resource + serviceName+authURI
+	   * @return Hashtable of hashtables represented by a pair: 
+	   * a name of the output = hashtable for this output 
+	   * hashtable for output is represented by a Output descriptor and value.
+	   * 
+	   */
+
+	public Hashtable getOutput(String resource){
+		int bagout = 0;
+		int so = 1;
+		int co = 1;
+        String simple = "ok";
+        String collection = "ok";
+
+		Hashtable output = new Hashtable();
+
+	   Resource si = servDescrMd.getResource(resource);
+	   
+	   
+	   try{
+				 Resource consumes = si.getRequiredProperty(MP.produces).getResource();					
+				 StmtIterator p23iter =  consumes.listProperties();       			
+			
+				 while (p23iter.hasNext()) {
+				
+					Hashtable simout = new Hashtable();
+					Hashtable colout = new Hashtable();
+					StringBuffer simpns = new StringBuffer();
+//					StringBuffer colons = new StringBuffer();
+				
+					 Statement l3iter = p23iter.nextStatement();
+					 Resource l3Res = l3iter.getResource();
+ 
+					 if (l3Res.isAnon()){	                 
+					  Object type = l3Res.getRequiredProperty(RDF.type).getObject();
+//System.out.println("type_out = "+type);		               
+					 if (type.equals(MRes.Simple)){     
+						 StmtIterator p34iter = l3Res.listProperties();
+					
+						 while (p34iter.hasNext()) {												
+							 Statement l4iter = p34iter.nextStatement();					   					 					   
+							 String l4Pred1 = l4iter.getPredicate().toString();
+							 String l4Node1 = l4iter.getObject().toString();	
+							 String[] result = l4Pred1.split("#");
+							 int i = (result.length)-1;
+			
+							 String name = getInpOutName(result[i]);
+							 if (name.equals("")){
+							   Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Simple output <"+result[i]+">");
+							   Report.add("BAD STRUCTURE: Unknown name of predicate for Simple output <"+result[i]+">");
+							   simple = "error";
+							   continue;
+							 }
+							 if (name.equals("type")){
+								 continue;
+							 }	
+							 String[] rezNode1 = l4iter.getObject().toString().split(":http:");
+							 String l4Nodestr = rezNode1[0];
+							 if (name.equals("namespace_type_uris")){
+								simout.remove("namespace_type_uris");
+								String lsid_nsp = switchURItoLSID(l4Nodestr);
+							   if (simpns.length()==0){
+									 simpns.append(lsid_nsp);
+							   }else{
+									 simpns.append(","+lsid_nsp);
+								}
+						 
+							   simout.put(name,simpns.toString());	
+							}
+							 else if (name.equals("object_type_uri")){						
+								 String lsid_nsp = switchURItoLSID(l4Nodestr);
+								 simout.put(name,lsid_nsp);
+							 }
+							 else{
+							   simout.put(name,l4Nodestr);								   
+							 }
+						 }
+						 if (simout.isEmpty()){
+						 }else{						
+							output.put("simout"+so,simout);   // to add Simple to Output
+							so+=1;					   
+							Enumeration num = simout.keys();
+					  
+					 }
+			  }	
+  			
+					 else if (type.equals(MRes.Collection) | type.equals(RDF.Bag)){
+//						 if (l3Res.hasProperty(RDF.type,RDF.Bag) && l3Res.hasProperty(RDF.li(1))){
+
+						 if (l3Res.hasProperty(RDF.li(1))){
+							 StmtIterator p34iter = l3Res.listProperties();
+							 
+							 if (l3Res.hasProperty(MP.article_name)){
+							   String col_artName = l3Res.getProperty(MP.article_name).getObject().toString();
+							   String[] rezNode = col_artName.split(":http:");
+							   col_artName = rezNode[0];
+							   colout.put("col_articleName",col_artName);						
+							 }	
+							  while (p34iter.hasNext()) {							
+								 Statement l4iter = p34iter.nextStatement();
+								 Property l4Pred = l4iter.getPredicate();
+								 Node l4Node = l4iter.getObject().asNode();
+                               							 
+								 if (l4Node.isBlank()){							   		
+									 Resource l4Res = l4iter.getResource();            
+									 StmtIterator p45iter = l4Res.listProperties();
+									 if(p45iter.hasNext()) {																		
+										 StringBuffer sumns = new StringBuffer();
+										 while (p45iter.hasNext()) {
+											 Statement l5iter = p45iter.nextStatement();
+											 String l5Pred = l5iter.getPredicate().toString();
+											 Node l5Node = l5iter.getObject().asNode();
+											 String[] result = l5Pred.split("#");
+											 int i = (result.length)-1;				
+											 String name = getInpOutName(result[i]);
+											  if (name.equals("")){
+												 Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Collection output <"+result[i]+">");
+												 Report.add("BAD STRUCTURE: Unknown name of predicate for Collection output <"+result[i]+">");
+												 String Collection = "error";
+												 break;
+											  }
+											 String[] rezNode = l5iter.getObject().toString().split(":http:");
+											 String l5Nodestr = rezNode[0];										
+											 if (name.equals("namespace_type_uris")){
+												 colout.remove("namespace_type_uris");
+												 String lsid_nsp = switchURItoLSID(l5Node.toString());
+												 if (sumns.length()==0){
+													 sumns.append(lsid_nsp);
+												 }else{
+													 sumns.append(","+lsid_nsp);
+												 }
+                                            
+												 colout.put(name,sumns.toString());
+//												 sumns.append(l5Node+",");
+											 }else if (name.equals("object_type_uri")){
+												 String lsid_nsp = switchURItoLSID(l5Node.toString());
+												 colout.put(name,lsid_nsp);
+											 }
+											 else{
+												  colout.put(name,l5Node);
+											 }
+										 }														
+											 output.put("colout"+co,colout);
+											 co+=1;
+											 Enumeration num = colout.keys();
+									}
+							}
+					    
+						 }    			
+						 }else{
+							 collection = "error";
+							 Report.doWrite("BAD STRUCTURE: The Collection output isn't 'Bag' type or have not members");
+							 Report.add("BAD STRUCTURE: The Collection output isn't 'Bag' type or have not members");
+	
+						 }
+					 }     
+			  }
+	   }
+		
+			if (simple.equals("error") | collection.equals("error")){
+			  output.put("output","error");
+			}	
+		 }catch(Exception e){
+			 Log.warning("Failed:"+ e);
+		 } 
+//System.out.println("output = "+output);		       
+		return output;
+	}
+
+
+/** mapping RDF data to the database data
+		   * @param name - the name of predicate in the RDF of service
+		   * @return String field name in database corresponding with this predicate 
+		   * 
+		   */
+	
+
+public String getFieldName(String name){
+	String res = "";
+
+	if (name.equals("publisher") | name.equals("authURI")){
+		ver[0] = 1;
+		res = "authURI";
+	}
+	else if (name.equals("coverage")){
+		ver[1] = 1;
+		res = "category";
+	}
+	else if (name.equals("creator") | name.equals("contactEmail")){
+		ver[2] = 1;
+		res = "contact_email";
+	}
+	else if (name.equals("source") ){
+		ver[3] = 1;
+		res = "URL";
+	}
+	else if (name.equals("performs_task") | name.equals("serviceType")){
+		ver[4] = 1;
+		res = "service_type_uri";
+	}
+	else if (name.equals("title") | name.equals("serviceName")){
+		ver[5] = 1;
+		res = "servicename";		
+	}
+	else if (name.equals("description") | name.equals("comment")){
+		ver[6] = 1;
+		res = "description";
+	}	
+	else if (name.equals("authoritative") ){
+		ver[7] = 1;
+		res = "authoritative";	
+	}	
+	else if (name.equals("signatureURL") ){			
+		res = "signatureURL";	
+		}			 		 
+
+ return res;
+}
+
+/** mapping RDF input/output data to the database data
+		   * @param name - the name of predicate in the RDF of service
+		   * @return String field name in database corresponding with this predicate 
+		   * 
+		   */
+
+public String getInpOutName(String name){
+	String res = "";
+	    if (name.equals("article_name") | name.equals("articleName")){			
+			res = "articleName";
+		}
+
+		else if (name.equals("object_type")){
+			res = "object_type_uri";
+		}		
+	    else if (name.equals("namespace_type")){
+			res = "namespace_type_uris";
+		}
+	     else if (name.equals("type")){
+			   res = "type";
+		   }
+
+	return res;
+}
+
+/** mapping RDF Secondary data to the database data
+		   * @param name - the name of predicate in the RDF of service
+		   * @return String field name in database corresponding with this predicate 
+		   * 
+		   */
+
+public String getSecondaryName(String name){
+	String res = "";
+		
+		if (name.equals("article_name") | name.equals("articleName")){
+			res = "article_name";
+		}	 
+			
+		if (name.equals("default_value")){			
+			res = "default";
+		}
+		if (name.equals("datatype")){			
+			res = "datatype";
+		}
+		if (name.equals("max")){			
+		  res = "max";
+		}
+		if (name.equals("min")){			
+			  res = "min";
+		}
+		if (name.equals("enum")){			
+			  res = "enum";
+		}
+	    if (name.equals("type")){			
+			  res = "type";
+		}
+	
+	return res;
+}
+
+public String switchURItoLSID(String uri){
+	String lsid = "";
+
+try{	
+
+ 
+  if (uri.substring(0,4).equals("http")){  
+     String[] result = uri.split("/");
+    if ((result.length)-1 > 0){
+  	  if (result[2].equals("biomoby.org")){
+  		String[] result1 = result[5].split("#");
+		if ((result1.length)-1 > 0){
+			if (result1[0].equals("Namespaces")){
+				lsid = "urn:lsid:biomoby.org:namespacetype:"+result1[1];
+			}
+			else if (result1[0].equals("Objects")){
+			     lsid = "urn:lsid:biomoby.org:objectclass:"+result1[1];
+		    }
+			else if (result1[0].equals("Services")){
+	        	 lsid = "urn:lsid:biomoby.org:servicetype:"+result1[1];
+			}
+		}	
+  	} 
+  	else {
+  	  lsid = uri;	
+  	}	
+  	}
+  }
+ 
+else if (uri.substring(0,3).equals("urn:")){
+  lsid = uri;	
+}
+else {
+ lsid = "";
+}		
+}catch (Exception e){ 
+//System.out.println("False: "+e);
+	 	
+}
+ return lsid;	
+}
 }
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.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/verifier/DataMngr.java	2005/04/07 22:32:12	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java	2005/04/14 16:14:21	1.3
@@ -1,20 +1,19 @@
 package org.biomoby.registry.rdfagent.verifier;
 
-import java.math.BigDecimal;
+import java.util.Hashtable;
+import org.biomoby.registry.rdfagent.util.*;
+
+import java.util.Collection;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Enumeration;
 import java.sql.Connection;
+import java.sql.SQLException;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
+import java.util.List;
 import java.util.Vector;
-
-import org.biomoby.registry.rdfagent.util.Constants;
-import org.biomoby.registry.rdfagent.util.DBConnector;
-import org.biomoby.registry.rdfagent.util.Log;
-import org.biomoby.registry.rdfagent.util.Report;
-import org.biomoby.registry.rdfagent.util.XMLBuilder;
+import java.math.BigDecimal;
 
 /**
  * @author Nina Opushneva
@@ -71,18 +70,20 @@
 					services.put(lastAddr,servNames);
 
 				} catch (SQLException e) {
-// Send a mail to the moby admin
-					Log.severe(e.getMessage());								   
+					Log.severe(e.getMessage());	
+//                    e.getMessage();							   
 				} finally{
 					try {
 						if (rs != null) rs.close();								
 					} catch (SQLException e) {
 						Log.severe(e.getMessage()); 
+//						e.getMessage();	
 					}
 					try {
 						if (ps != null) ps.close();
 					} catch (SQLException e) {
 						Log.severe(e.getMessage());
+//						e.getMessage();	
 					}                           
 				}
 //System.out.println("ListOFServices : "+services);
@@ -133,33 +134,45 @@
                         services.put(lastAddr,servNames);
 
                     } catch (SQLException e) {
-// Send a mail to the moby admin
+//						e.getMessage();	
                         Log.severe(e.getMessage());
                     } finally{
                         try {
                             if (rs != null) rs.close();
                         } catch (SQLException e) {
+//							e.getMessage();	
                             Log.severe(e.getMessage());
                         }
                         try {
                             if (ps != null) ps.close();
                         } catch (SQLException e) {
                             Log.severe(e.getMessage());
-                        }
+//	                        e.getMessage();	
+	                   }
                     }
-    System.out.println("ListOFServices : "+services);
+//   System.out.println("ListOFServices : "+services);
 
             return services;
     }
 
 
 
- /** get the properties for a given section
-		* @param 
+ /** This method use for the  update service_instance table, simple_input/output table,
+        *  collection_input/output table, secondary_input table in accordance with data
+        *  from RDF file.
+		* @param Hashtable servSign - set of the serviceSignature data (name - value, an example: servicename - GoTerm);
+		* Hashtable of hashtables represented by a pair: 
+	    * a name of the input = hashtable for this output 
+		* example:{siminp1={object_type_uri=urn:lsid:biomoby.org:objectclass:Object, namespace_type_uris=urn:lsid:biomoby.org:namespacetype:taxon}}
+        * @param  Hashtable of hashtables represented by a pair: 
+	    * a name of the output = hashtable for this output 
+	    * @param servname - the name of service
+	    * @param authURI - the authority URI
+	    * @param signURL - URL of resource
 		* @return .
 		*/
 
-	public static int processService( Hashtable servSign, Hashtable servInp, Hashtable servOut, String servname,String authURI,String signURL){
+	public static void processService( Hashtable servSign, Hashtable servInp, Hashtable servOut, String servname,String authURI,String signURL){
 
 		Connection con = DBConnector.getConnection();
 
@@ -184,7 +197,8 @@
 				
 	  String enumsec = null;
       int colId = 0;
-      int coloutId = 0;
+      Integer colOutId = null;
+      Integer colInpId = null;
       int serv =0;                          // a flag - the given service was found	
       int checkServ = 0;                    // a flag - the service exist in the database
       int new_serv = 0;                     // the number of new services 
@@ -259,14 +273,15 @@
        }
 		
 		if (ret ==1){
-          String msg = "------THE SERVICE INSTANCE  <"+servName+">  WAS REGISTERED IN THE mobycentral REGISTRY ";
+          String msg = "------The service instance  <"+servName+">  was registered in the MOBYCENTRAL registry ";
           Report.doWrite(msg);
-System.out.println("mail_server = "+Constants.MB_MAIL_SERVER);          
-          if (Constants.MB_MAIL_SERVER != null) {
+		  Report.add(msg);	
+          
+//System.out.println("mail_server = "+Constants.MB_MAIL_SERVER);          
+/*          if (Constants.MB_MAIL_SERVER != null | Constants.MB_MAIL_SERVER.equals("")) {
 		      String to = DataMngr.getContactEmail(signURL);
 		      Communicator.sendMail(to,Constants.SP_SUBJECT,msg,Constants.MB_FROM); // send message to the service provider - that service was deregistered
-              Report.doWrite("The message have been sent to "+to);
-	      }
+	      }*/
 		  new_serv +=1;
 		  servInstId = getServInstId(servName,authId);
 		}			
@@ -276,17 +291,20 @@
 	        !email.equals(signature.getEmail()) | !desc.equals(signature.getDescription()) |
 	        !stype.equals(signature.getServiceType()) | !authoritative.equals(signature.getAuthoritative()) |
 	        !authuri.equals(authURI) ){
+
 	        					
 		    if (signatureURL.equals("NNN")){
 			   int res = updSign(servName,cat,stype,authuri,url,email,desc,authoritative,signURL);	
                 if (res == 1){
-                 Report.doWrite("------THE SERVICE INSTANCE  <"+servName+">  WAS UPDATED ");	
+ //               Report.doWrite("------The service instance <"+servName+">  was updated ");
+//				 Report.add("------The service instance <"+servName+">  was updated ");		
                 }
 
 		    }else{
 			  int res = updSign(servName,cat,stype,authuri,url,email,desc,authoritative,signatureURL);
 			  if (res == 1){
-				Report.doWrite("------THE SERVICE INSTANCE  <"+servName+">  WAS UPDATED ");	
+//				Report.doWrite("------The service instance  <"+servName+">  was updated ");
+//				Report.add("------The service instance  <"+servName+">  was updated ");	
 			  }
 		    }
         }					
@@ -295,34 +313,54 @@
 
 	  
 // ************ add Input *********************
+
 	   
 	   Enumeration num1 = servInp.keys();
         int dels = 0;
         int delc = 0;
         int delsec = 0;
+        int si =0;
+        int ci = 0;
+        int sci = 0;
+
 		while (num1.hasMoreElements()){
 		    Object ob = num1.nextElement();
 		    Object val  = servInp.get(ob);
-
+//System.out.println(ob+" = "+val );
             String simcol = (ob.toString()).substring(0,6);   // a hashtable name
 	
 		    if (simcol.equals("secinp")){    // if it's a Secondary input
+             sci += 1;
+			 Report.doWrite(" ");
+			 Report.add(" ");
+             Report.doWrite("Secondary input "+sci);
+			 Report.add("Secondary input "+sci+":");
 				if (delsec == 0){
 					delRow("secondary_input",servInstId);       // delete  from simple_input table
 					delsec = 1;              
 				}
 		    }
             else if (simcol.equals("colinp")){  // if it's a Collection input
+              ci += 1; 
+			  Report.doWrite(" ");
+			  Report.add(" ");
+              Report.doWrite("Collection input "+ci);
+			  Report.add("Collection input "+ci+":");
 				if (delc == 0){
-                   int colInpId = getCollectionId("collection_input","collection_input_id",servInstId);
+ //                 colInpId = new Integer(getCollectionId("collection_input","collection_input_id",servInstId));
+				   delCollectionMember("input",servInstId);       // delete  from simple_input table
 			       delRow("collection_input",servInstId);   // delete  from the collection_input table
-				   delCollectionMember("simple_input","collection_input_id",servInstId,colInpId);       // delete  from simple_input table
 				   delc = 1;
 				}
                 
              }else {                              // if it's a Simple input  
+				Report.doWrite(" ");
+				Report.add(" ");
+				si += 1;
+				Report.doWrite("Simple input "+si);
+                Report.add("Simple input "+si+":");
                  if (dels == 0){
-				  delCollectionMember("simple_input","collection_input_id",servInstId,0);       // delete  from simple_input table
+				  delRow("simple_input",servInstId);       // delete  from simple_input table
                   dels = 1;
                     }
                 }
@@ -330,9 +368,14 @@
 			simple = (Hashtable) val;
 			Enumeration num11 = simple.keys();
 
-					
+				
 			while (num11.hasMoreElements()){	
 				Object ob1 = num11.nextElement();
+                if (!ob1.equals("type")){	
+					Report.doWrite(ob1+" = "+simple.get(ob1));
+					Report.add(ob1+" = "+simple.get(ob1)); 				
+                }
+				
 				if(ob1.equals("col_articleName")){
 					col_art = simple.get(ob1).toString();
 					if (col_art.equals(" ")){
@@ -367,9 +410,10 @@
 					String maxsec_s = simple.get(ob1).toString();
 					try{								
 						 maxsec = new BigDecimal(maxsec_s);
-						 																
+					 																
 					}catch(NumberFormatException nx){
-						Log.severe(nx.getMessage());
+				Log.severe(nx.getMessage());
+//				nx.getMessage();	
 					}
 				}							
 				else if(ob1.equals("min")){
@@ -378,7 +422,8 @@
 						 minsec = new BigDecimal(minsec_s);
 						 
 					 }catch(NumberFormatException nx){
-					 	Log.severe(nx.getMessage());
+				 	Log.severe(nx.getMessage());
+//	                  nx.getMessage();	
 					 }														 
 				}						
 				else if(ob1.equals("enum")){
@@ -387,38 +432,32 @@
 			}			
 
 			if (simcol.equals("colinp")){
-				int minNum = getMinFreeNumber("collection_input","collection_input_id");
-				if (minNum==0){
-					insIntoCol("collection_input",col_art,servInstId);    // insert the row into collection_input  table						 					
-				}else{
-					updateCol("collection_input","collection_input_id",col_art,servInstId,minNum);
-				}				
-				    colId = getCollectionId("collection_input","collection_input_id",servInstId);		
-				    int minSimpNum = getMinFreeNumber("simple_input","simple_input_id");
-				    if (minSimpNum==0){
-						insIntoSimpleInput(servInstId,art,obt,nst,colId);
-				    }else{
-				    	updateSimpleInput(servInstId,art,obt,nst,colId,minSimpNum);
-				    }
-				    							
+				insIntoCol("collection_input",col_art,servInstId);    // insert the row into collection_input  table						 								
+			    colId = getCollectionId("collection_input","collection_input_id",servInstId);		
+				insIntoSimpleInput(null,art,obt,nst,new Integer(colId));
+
+				 art = null;
+				 col_art = null;
+				 obt = null;
+				 nst = null; 							
 				}
 			    else if (simcol.equals("siminp")){	
-				   int minSimpNum = getMinFreeNumber("simple_input","simple_input_id");
-				   if (minSimpNum==0){
-					   insIntoSimpleInput(servInstId,art,obt,nst,0);
-				   }else{
-					   updateSimpleInput(servInstId,art,obt,nst,0,minSimpNum);
-				   }		    	
-											
+				   insIntoSimpleInput(new Integer(servInstId),art,obt,nst,null);
+		    	
+				    art = null;						
+					obt = null;
+					nst = null;						
 			    }
 			    else if (simcol.equals("secinp")){	
-                     int minSecNum = getMinFreeNumber("secondary_input","secondary_input_id");
-					if (minSecNum==0){
+
 						insIntoSecondary(servInstId,artsec,defsec,dtsec,maxsec,minsec,enumsec);
-				    }else{
-					  updateSec(servInstId,artsec,defsec,dtsec,maxsec,minsec,enumsec,minSecNum);
-				    }		    	
-			    			
+    	
+					 artsec = null;
+					 defsec = null;
+					 dtsec = null;	 
+					 maxsec  = null;
+					 minsec  = null;				
+					 enumsec = null;		
 			    }
 			    
 			    if (colId != 0){
@@ -436,29 +475,49 @@
 	       Enumeration numout = servOut.keys();
            int delsout = 0;
            int delcout = 0;
+           int so = 0;
+           int co = 0;
 			while (numout.hasMoreElements()){
 			    Object ob = numout.nextElement();
 			    Object val  = servOut.get(ob);
                 String simcol = (ob.toString()).substring(0,6);
 			   
 				if (simcol.equals("colout")){
+					co += 1;
+					Report.doWrite(" ");
+					Report.add(" ");
+			    	Report.doWrite("Collection output "+co);
+				    Report.add("Collection output "+co+":");	
                    if (delcout == 0){
-					 int colOutId = getCollectionId("collection_output","collection_output_id",servInstId);
+//					colOutId = new Integer(getCollectionId("collection_output","collection_output_id",servInstId));
+					  delCollectionMember("output",servInstId);      // delete  from table simple_output
 					  delRow("collection_output",servInstId);   // delete  from the collection_output table
-                      delCollectionMember("simple_output","collection_output_id",servInstId,colOutId);      // delete  from table simple_output
                       delcout = 1;
                    }
          	   } else{
+         	   	    so += 1;
+				    Report.doWrite(" ");
+					Report.add(" ");
+         			Report.doWrite("Simple output "+so);
+		    		Report.add("Simple output "+so+":");	
+
                     if (delsout == 0){
-				    	delCollectionMember("simple_output","collection_output_id",servInstId,0);      // delete  from  simple_output table
+				    	delRow("simple_output",servInstId);      // delete  from  simple_output table
                         delsout = 1;
                     }
                  }
                	Hashtable simple = new Hashtable();
 				simple = (Hashtable) val;
 				Enumeration num11 = simple.keys();
+//				Report.doWrite(""+simple);
+				
 				while (num11.hasMoreElements()){
  				  Object ob1 = num11.nextElement();
+ 				  if(!ob1.equals("type")){
+					Report.doWrite(ob1+" = "+simple.get(ob1)); 	
+					Report.add(ob1+" = "+simple.get(ob1));
+ 				  }
+			  
                   if(ob1.equals("col_articleName")){
 					 col_art = simple.get(ob1).toString();
 					 if (col_art.equals(" ")){
@@ -480,41 +539,24 @@
 			}
 				 
 				 if (simcol.equals("colout")){
-				 	int minNum = getMinFreeNumber("collection_output","collection_output_id");
 
-                    if (minNum==0){
 						insIntoCol("collection_output",col_art,servInstId);    // insert the row into collection_input  table
-                    }else{
-                    	updateCol("collection_output","collection_output_id",col_art,servInstId,minNum);
-                    }
                     
-			        coloutId = getCollectionId("collection_output","collection_output_id",servInstId);
-					int minSimpNum = getMinFreeNumber("simple_output","simple_output_id");
-					if (minSimpNum==0){
-						insIntoSimpleOutput(servInstId,art,obt,nst,coloutId);
-					}else{
-						updateSimpleOutput(servInstId,art,obt,nst,coloutId,minSimpNum);
-					}
-										
+			        colOutId = new Integer(getCollectionId("collection_output","collection_output_id",servInstId));
+						insIntoSimpleOutput(null,art,obt,nst,colOutId);										
                          art = null;
 	                     obt = null;
 	                     nst = null;
 				}
 				if (simcol.equals("simout")){
-					int minSimpNum = getMinFreeNumber("simple_output","simple_output_id");
-					if (minSimpNum==0){
-						insIntoSimpleOutput(servInstId,art,obt,nst,0);
-					}else{
-						updateSimpleOutput(servInstId,art,obt,nst,0,minSimpNum);
-					}
-											
+						insIntoSimpleOutput(new Integer(servInstId),art,obt,nst,null);											
 				}
-				if (coloutId != 0){				
-				  Report.doWrite("collection_output_id: "+coloutId);
+				if (colOutId != null){				
+				  Report.doWrite("collection_output_id: "+colOutId);
 //                  Log.info("collection_output_id: "+coloutId);
 				}
 			  }
-	return serv;
+//	return serv;
 	}
 
 
@@ -532,6 +574,8 @@
 		delSignature(servName,authId);                                 // delete service from table service_instance
        	delRow("simple_input",servInstId);       // delete  from table simple_input
         delRow("simple_output",servInstId);      // delete  from table simple_output
+        delCollectionMember("input",servInstId);
+		delCollectionMember("output",servInstId);
 		delRow("collection_input",servInstId);   // delete  from table collection_input
 		delRow("collection_output",servInstId);  // delete  from table collection_output
 	}
@@ -547,9 +591,11 @@
 			int authId = getAuthIdByServNameAndSignURL(servName,signURL);
 			int servInstId = getServInstId(servName,authId);
 
-			delSignature(servName,authId);                                        // delete service from table service_instance
+			delSignature(servName,authId);           // delete service from table service_instance
 			delRow("simple_input",servInstId);       // delete  from table simple_input
 			delRow("simple_output",servInstId);      // delete  from table simple_output
+            delCollectionMember("input",servInstId);
+		    delCollectionMember("output",servInstId);
 			delRow("collection_input",servInstId);   // delete  from table collection_input
 			delRow("collection_output",servInstId);  // delete  from table collection_output
 		}
@@ -582,6 +628,8 @@
 			 }
 			 delRow("simple_input",servInstId);       // delete  from table simple_input
 			 delRow("simple_output",servInstId);      // delete  from table simple_output
+			 delCollectionMember("input",servInstId); // delete collection member from simple_input
+			 delCollectionMember("output",servInstId); // delete collection member from simple_output
 			 delRow("collection_input",servInstId);   // delete  from table collection_input
 			 delRow("collection_output",servInstId);  // delete  from table collection_output
 			}
@@ -601,6 +649,7 @@
 				
 		} catch (SQLException e) {
 			Log.severe(e.getMessage());
+//			e.getMessage();	
 		} finally{
 			try {
 			  if (rs != null) rs.close();
@@ -652,13 +701,14 @@
 				ret = ps.executeUpdate();
 
 			} catch (SQLException e) {
-// Send mail to moby admin
 			   Log.severe(e.getMessage());
+//			   e.getMessage();	
 			} finally{
 				try {
 					if (ps != null) ps.close();
 				} catch (SQLException e) {
 					Log.severe(e.getMessage());
+//					e.getMessage();	
 				}
 			}
 	return ret;
@@ -709,13 +759,14 @@
                       }
 
                      } catch (SQLException e) {
-						 // Send mail to moby admin
+//					e.getMessage();	
 						Log.severe(e.getMessage());
 					 } finally{
 						 try {
 							 if (ps != null) ps.close();
 						 } catch (SQLException e) {
 							Log.severe(e.getMessage());
+//							e.getMessage();	
 						 }
 					 }
 			 return ret;
@@ -730,7 +781,7 @@
         * @return ret=1 if the record has added, and ret=-1 otherwise
 		*/
 
-	public static void insIntoSimpleInput(int servInstId,String articleName,String objTypeUri,String nsTypeUris,int colInpId){
+	public static void insIntoSimpleInput(Integer servInstId,String articleName,String objTypeUri,String nsTypeUris,Integer colInpId){
 	
         	Connection con = DBConnector.getConnection();
 
@@ -740,23 +791,32 @@
 		
 				PreparedStatement ps = null;
 				try {
-					ps = con.prepareStatement(sqlReq1);
-					ps.setInt(1, servInstId);
+					ps = con.prepareStatement(sqlReq1);					
+					if (servInstId != null){
+					  ps.setInt(1, servInstId.intValue());
+					} else {
+					  ps.setNull(1, java.sql.Types.INTEGER);
+					}
 					ps.setString(2, articleName);
                    	ps.setString(3, objTypeUri);
                    	ps.setString(4, nsTypeUris);
-                   	ps.setInt(5, colInpId);
+					if (colInpId != null){
+						 ps.setInt(5, colInpId.intValue());
+					 } else {
+						  ps.setNull(5, java.sql.Types.INTEGER);
+					}
 
 					ret = ps.executeUpdate();
 
 					} catch (SQLException e) {
-							// Send mail to moby admin
-						   Log.severe(e.getMessage());
+//					   e.getMessage();	
+					   Log.severe(e.getMessage());
 					} finally{
 						try {
 						   if (ps != null) ps.close();
 						} catch (SQLException e) {
 							Log.severe(e.getMessage());
+//							e.getMessage();	
 						}
 				}
 }
@@ -770,7 +830,7 @@
 		* @return ret=1 if the record has added, and ret=-1 otherwise
 		*/
 
-	public static int updateSimpleInput(int servInstId,String articleName,String objTypeUri,String nsTypeUris,int colInpId,int minNum){
+	public static int updateSimpleInput(int servInstId,String articleName,String objTypeUri,String nsTypeUris,Integer colInpId,int minNum){
 	
 			Connection con = DBConnector.getConnection();
 
@@ -785,18 +845,23 @@
 					ps.setString(2, articleName);
 					ps.setString(3, objTypeUri);
 					ps.setString(4, nsTypeUris);
-					ps.setInt(5, colInpId);
+					if (colInpId != null){
+						 ps.setInt(5, colInpId.intValue());
+					 } else {
+						  ps.setNull(5, java.sql.Types.INTEGER);
+					}					
 					ps.setInt(6, minNum);
 					ret = ps.executeUpdate();
 
 					} catch (SQLException e) {
-							// Send mail to moby admin
 						   Log.severe(e.getMessage());
+//				        	e.getMessage();	
 					} finally{
 						try {
 						   if (ps != null) ps.close();
 						} catch (SQLException e) {
-							Log.severe(e.getMessage());
+						Log.severe(e.getMessage());
+//							e.getMessage();	
 						}
 				}
         return ret;
@@ -814,7 +879,7 @@
         * @return ret=1 if the record has added, and ret=-1 otherwise
 		*/
 
-	public static void insIntoSecondary(int servInstId,String article_name,String def,String dataType,BigDecimal max,BigDecimal min,String _enum){
+	public static void insIntoSecondary(int servInstId,String article_name,String def,String dataType,BigDecimal max,BigDecimal min,String enum){
 	
 				Connection con = DBConnector.getConnection();
 
@@ -830,19 +895,20 @@
 							ps.setString(3, def);
 						    ps.setBigDecimal(4, max);
 							ps.setBigDecimal(5, min);
-							ps.setString(6, _enum);
+							ps.setString(6, enum);
 							ps.setString(7, dataType);
 
 							ret = ps.executeUpdate();
 
 						} catch (SQLException e) {
-								// Send mail to moby admin
-							   Log.severe(e.getMessage());
+						   Log.severe(e.getMessage());
+//	                          e.getMessage();	
 						} finally{
 							try {
 								if (ps != null) ps.close();
 						    } catch (SQLException e) {
 								Log.severe(e.getMessage());
+//								e.getMessage();	
 							}
 						}
 		}
@@ -860,7 +926,7 @@
 			* @return ret=1 if the record has added, and ret=-1 otherwise
 			*/
 
-		public static void updateSec(int servInstId,String article_name,String def,String dataType,BigDecimal max,BigDecimal min,String _enum, int minSecNum){
+		public static void updateSec(int servInstId,String article_name,String def,String dataType,BigDecimal max,BigDecimal min,String enum, int minSecNum){
 	
 					Connection con = DBConnector.getConnection();
 
@@ -876,18 +942,19 @@
 								ps.setString(3, def);
 								ps.setBigDecimal(4, max);
 								ps.setBigDecimal(5, min);
-								ps.setString(6, _enum);
+								ps.setString(6, enum);
 								ps.setString(7, dataType);
 								ps.setInt(8, minSecNum);
 								ret = ps.executeUpdate();
 
 							} catch (SQLException e) {
-									// Send mail to moby admin
+//								e.getMessage();	
 								   Log.severe(e.getMessage());
 							} finally{
 								try {
 									if (ps != null) ps.close();
 								} catch (SQLException e) {
+//									e.getMessage();	
 									Log.severe(e.getMessage());
 								}
 							}
@@ -904,7 +971,7 @@
         * @return ret=1 if the record has added, and ret=-1 otherwise
 		*/
 
-	public static void insIntoSimpleOutput(int servInstId,String articleName,String objTypeUri,String nsTypeUris,int colOutId){
+	public static void insIntoSimpleOutput(Integer servInstId,String articleName,String objTypeUri,String nsTypeUris,Integer colOutId){
 	
         Connection con = DBConnector.getConnection();
 
@@ -918,23 +985,33 @@
                             try {
                                 ps = con.prepareStatement(sqlReq1);
 
-                                ps.setInt(1, servInstId);
+                              
+								if (servInstId != null){
+								  ps.setInt(1, servInstId.intValue());
+								} else {
+								  ps.setNull(1, java.sql.Types.INTEGER);
+								}
                                 ps.setString(2, articleName);
                                 ps.setString(3, objTypeUri);
                                 ps.setString(4, nsTypeUris);
-                                ps.setInt(5, colOutId);
+								if (colOutId != null){
+						          ps.setInt(5, colOutId.intValue());
+					            } else {
+						          ps.setNull(5, java.sql.Types.INTEGER);
+					            }
+
 
                                 ret = ps.executeUpdate();
 
                             } catch (SQLException e) {
-                                // Send mail to moby admin
- //                              e.printStackTrace();
+//								e.getMessage();	
                                  Log.severe(e.getMessage());
                             } finally{
                                 try {
                                     if (ps != null) ps.close();
                                 } catch (SQLException e){                               
 									Log.severe(e.getMessage());
+//									e.getMessage();	
                                 }
 							 
                                   
@@ -976,14 +1053,14 @@
 								ret = ps.executeUpdate();
 
 							} catch (SQLException e) {
-								// Send mail to moby admin
- //                              e.printStackTrace();
+//								e.getMessage();	
 								 Log.severe(e.getMessage());
 							} finally{
 								try {
 									if (ps != null) ps.close();
 								} catch (SQLException e){                               
 									Log.severe(e.getMessage());
+//									e.getMessage();	
 								}
 							 
                                   
@@ -1022,18 +1099,20 @@
 			}
 
 		} catch (SQLException e) {
-					// Send mail to moby admin
+//			e.getMessage();	
 			Log.severe(e.getMessage());
 				} finally{
 					try {
 						if (rs != null) rs.close();
 					} catch (SQLException e) {
 						Log.severe(e.getMessage());
+//						e.getMessage();	
 					}
 					try {
 						if (ps != null) ps.close();
 					} catch (SQLException e) {
 						Log.severe(e.getMessage());
+//						e.getMessage();	
 					}
 
 				}
@@ -1084,18 +1163,20 @@
 				}
 
 			} catch (SQLException e) {
-						// Send mail to moby admin
+//				e.getMessage();	
 				Log.severe(e.getMessage());
 					} finally{
 						try {
 							if (rs != null) rs.close();
 						} catch (SQLException e) {
 							Log.severe(e.getMessage());
+//							e.getMessage();	
 						}
 						try {
 							if (ps != null) ps.close();
 						} catch (SQLException e) {
 							Log.severe(e.getMessage());
+//							e.getMessage();	
 						}
 
 					}
@@ -1141,18 +1222,20 @@
 					}
 
 				} catch (SQLException e) {
-							// Send mail to moby admin
+//					e.getMessage();	
 					Log.severe(e.getMessage());
 						} finally{
 							try {
 								if (rs != null) rs.close();
 							} catch (SQLException e) {
+//								e.getMessage();	
 								Log.severe(e.getMessage());
 							}
 							try {
 								if (ps != null) ps.close();
 							} catch (SQLException e) {
 								Log.severe(e.getMessage());
+//								e.getMessage();	
 							}
 
 						}
@@ -1184,9 +1267,10 @@
 			   String artName = rs.getString(1);						   					   
 			   String nsType = rs.getString(2);
 			   String objType = rs.getString(3);			   
-			   int colOutId = rs.getInt(4);
+//			   int colOutId = rs.getInt(4);
 			   String type;
-			   if (colOutId == 0){
+			   Integer colOutId = new Integer(rs.getInt(4));
+			   if (colOutId == null){
 			   	  type = "so";
 			   }else{
 			   	  type = "co";
@@ -1195,18 +1279,20 @@
 			   XMLBuilder.buildInpOutXml(artName,nsType,objType,type);
 		   }
 		   } catch (SQLException e) {
-	   // Send mail to moby admin
+//		e.getMessage();	
 			   Log.severe(e.getMessage());
 		   } finally{
 			   try {
         		   if (rs != null) rs.close();
 			   } catch (SQLException e) {
 				   Log.severe(e.getMessage());
+//				e.getMessage();	
 			   }
 				   try {
 					   if (ps != null) ps.close();
 				   } catch (SQLException e) {
 					   Log.severe(e.getMessage());
+//					e.getMessage();	
 				   }
 		   }				   	
    }
@@ -1220,7 +1306,7 @@
    public static void getSimpleCollectInput(int servInstId){
 						 
 	   Connection con = DBConnector.getConnection();
-
+           
 		   final String sqlReq1 = "select article_name,namespace_type_uris,object_type_uri,collection_input_id from simple_input where service_instance_id = ?";
 		   PreparedStatement ps = null;
 		   ResultSet rs = null;
@@ -1235,8 +1321,9 @@
 				   String nsType = rs.getString(2);
 				   String objType = rs.getString(3);
 				   String type;
-				   int colInpId = rs.getInt(4);
-				   if (colInpId == 0){
+//				   int colInpId = rs.getInt(4);
+                   Integer colInpId = new Integer(rs.getInt(4));
+				   if (colInpId == null){
 					  type = "si";
 				   }else{
 					  type = "ci";
@@ -1246,18 +1333,20 @@
 	    	   }
 
 		  } catch (SQLException e) {
-			   // Send mail to moby admin
-		     Log.severe(e.getMessage());
+//			e.getMessage();	
+		    Log.severe(e.getMessage());
 		    } finally{
 		      try {
 			    if (rs != null) rs.close();
 		      } catch (SQLException e) {
 			     Log.severe(e.getMessage());
+//				e.getMessage();	
 		        }
 				try {
 				   if (ps != null) ps.close();
 				} catch (SQLException e) {
 					   Log.severe(e.getMessage());
+//					e.getMessage();	
 				   }
 
    }				   	
@@ -1288,13 +1377,14 @@
 						 ret = ps.executeUpdate();
 
 					 } catch (SQLException e) {
-						 // Send mail to moby admin
+
 						Log.severe(e.getMessage());
 					 } finally{
 						 try {
 							 if (ps != null) ps.close();
 						 } catch (SQLException e) {
 							Log.severe(e.getMessage());
+//							e.getMessage();	
 						 }
 
 					 }
@@ -1328,13 +1418,14 @@
 							 ret = ps.executeUpdate();
 
 						 } catch (SQLException e) {
-							 // Send mail to moby admin
+//							e.getMessage();	
 							Log.severe(e.getMessage());
 						 } finally{
 							 try {
 								 if (ps != null) ps.close();
 							 } catch (SQLException e) {
 								Log.severe(e.getMessage());
+//								e.getMessage();	
 							 }
 
 						 }
@@ -1364,11 +1455,13 @@
 
 				} catch (SQLException e) {
 				   Log.warning(e.getMessage());
+//				   e.getMessage();	
 				} finally{
 				try {
 				 if (ps != null) ps.close();
 				} catch (SQLException e) {
 					Log.severe(e.getMessage());
+//					e.getMessage();	
 				}	
 	}
 			return ret;
@@ -1403,6 +1496,7 @@
 
 					} catch (SQLException e) {
 						Log.severe(e.getMessage());
+//						e.getMessage();	
 						} finally{
 							try {
 							  if (rs != null) rs.close();
@@ -1412,6 +1506,7 @@
 									if (ps != null) ps.close();
 								} catch (SQLException e) {
 									Log.severe(e.getMessage());
+//									e.getMessage();	
 								}
 
 							}
@@ -1447,6 +1542,7 @@
 
 						} catch (SQLException e) {
 							Log.severe(e.getMessage());
+//							e.getMessage();	
 							} finally{
 								try {
 								  if (rs != null) rs.close();
@@ -1456,6 +1552,7 @@
 										if (ps != null) ps.close();
 									} catch (SQLException e) {
 										Log.severe(e.getMessage());
+//										e.getMessage();	
 									}
 
 								}
@@ -1489,6 +1586,7 @@
 
 						} catch (SQLException e) {
 							Log.severe(e.getMessage());
+//							e.getMessage();	
 							} finally{
 								try {
 								  if (rs != null) rs.close();
@@ -1498,6 +1596,7 @@
 										if (ps != null) ps.close();
 									} catch (SQLException e) {
 										Log.severe(e.getMessage());
+//										e.getMessage();	
 									}
 
 								}
@@ -1517,7 +1616,8 @@
 
 	    	int ret = -1;
 
-					final String sqlReq1 = "update "+tableName+" set service_instance_id = 0 where service_instance_id = ?";
+					final String sqlReq1 = "delete from "+tableName+" where service_instance_id = ?";
+
 					PreparedStatement ps = null;
 
 
@@ -1530,11 +1630,13 @@
 
 							} catch (SQLException e) {
 								Log.severe(e.getMessage());
+//								e.getMessage();	
 							} finally{
 								try {
 									if (ps != null) ps.close();
 								} catch (SQLException e) {
 									Log.severe(e.getMessage());
+//									e.getMessage();	
 								}
 
 							}
@@ -1547,34 +1649,61 @@
 	 * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise.
 	 */
 
-	public static int delCollectionMember(String tableName, String key_field,int servInstId, int colInpId){
+	public static void delCollectionMember(String inout, int servInstId){
 
 			Connection con = DBConnector.getConnection();
 
-	    	int ret = -1;
-
-					final String sqlReq1 = "update "+tableName+" set service_instance_id = 0 where service_instance_id = ? and "+key_field+" = ?";
-					PreparedStatement ps = null;
-
-
+	    	final String sqlReq1;
+//System.out.println("inout = "+inout);	    	
+	    	if (inout.equals("input")){		 
+			  sqlReq1 = "select collection_input_id from collection_input where service_instance_id = ?  ";
+	    	}else{
+			  sqlReq1 = "select collection_output_id from collection_output where service_instance_id = ?  ";		
+	    	}
+//System.out.println("sqlReq1 = "+sqlReq1);	    	
+   			   PreparedStatement ps = null;
+   			   ResultSet rs = null;
+				try {
+					ps = con.prepareStatement(sqlReq1);
+					ps.setInt(1, servInstId);
+					rs = ps.executeQuery();
+						while (rs.next()) {	
+							int colId = rs.getInt(1);
+//System.out.println("colId = "+colId);							
+							final String sqlReq;
+							if (inout.equals("input")){
+								sqlReq = "delete from simple_input where collection_input_id="+colId;
+//System.out.println("sqlReq = "+sqlReq);												
+							}else{
+								sqlReq = "delete from simple_output where collection_output_id="+colId;				
+							}
+							PreparedStatement ps1 = null;
+							
 							try {
-								ps = con.prepareStatement(sqlReq1);
-
-								ps.setInt(1, servInstId);
-                                ps.setInt(2, colInpId);
-								ret = ps.executeUpdate();
-
+								ps1 = con.prepareStatement(sqlReq);
+//							    ps.setInt(1, servInstId);
+								 ps1.executeUpdate();
 							} catch (SQLException e) {
 								Log.severe(e.getMessage());
 							} finally{
 								try {
-									if (ps != null) ps.close();
+								  if (ps1 != null) ps1.close();
 								} catch (SQLException e) {
 									Log.severe(e.getMessage());
-								}
-
-							}
-					return ret;
+								  }
+								  }					
+						 } 
+								
+				} catch (SQLException e) {
+					Log.severe(e.getMessage());
+				} finally{
+					try {
+						if (ps != null) ps.close();
+					} catch (SQLException e) {
+						Log.severe(e.getMessage());
+					  }
+				  }
+					
 				}
 
   /** delete a record from service_instance table  by a servicename and authority Id
@@ -1598,11 +1727,13 @@
 								ret = ps.executeUpdate();
 							} catch (SQLException e) {
                             	Log.severe(e.getMessage());
+ //                               e.getMessage();	
 							} finally{
 								try {
 									if (ps != null) ps.close();
 								} catch (SQLException e) {
 									Log.severe(e.getMessage());
+//									e.getMessage();	
 								}
 							}
 					return ret;
@@ -1630,23 +1761,26 @@
 						   rs = ps.executeQuery();
 
 						   while (rs.next()) {
-							   colId = rs.getInt(1);
-													
+							  colId = rs.getInt(1);
+							 			
 						   }
 
 					   } catch (SQLException e) {
 
 						       Log.severe(e.getMessage());
+//						       e.getMessage();	
 							   } finally{
 								   try {
 									   if (rs != null) rs.close();
 								   } catch (SQLException e) {
 									  Log.severe(e.getMessage());
+//									  e.getMessage();	
 								   }
 								   try {
 									   if (ps != null) ps.close();
 								   } catch (SQLException e) {
 								    	Log.severe(e.getMessage());
+//									    e.getMessage();	
 								   }
 
 							   }
@@ -1681,11 +1815,13 @@
 
 						 } catch (SQLException e) {
 								Log.severe(e.getMessage());
+//						    e.getMessage();	
 						 } finally{
 							 try {
 								 if (ps != null) ps.close();
 							 } catch (SQLException e) {
 								Log.severe(e.getMessage());
+//								e.getMessage();	
 							 }
 						 }
 					 return ret;
@@ -1721,11 +1857,13 @@
 
 							 } catch (SQLException e) {
 									Log.severe(e.getMessage());
+//							   e.getMessage();	
 							 } finally{
 								 try {
 									 if (ps != null) ps.close();
 								 } catch (SQLException e) {
 									Log.severe(e.getMessage());
+//									e.getMessage();	
 								 }
 							 }
 						 return ret;
@@ -1759,16 +1897,19 @@
 
 			} catch (SQLException e) {
 				Log.severe(e.getMessage());
+//				e.getMessage();	
 					} finally{
 						try {
 							if (rs != null) rs.close();
 						} catch (SQLException e) {
 							Log.severe(e.getMessage());
+//							e.getMessage();	
 						}
 						try {
 							if (ps != null) ps.close();
 						} catch (SQLException e) {
 							Log.severe(e.getMessage());
+//							e.getMessage();	
 						}
 
 					}
@@ -1806,6 +1947,7 @@
 
 				   } catch (SQLException e) {
 					   Log.severe(e.getMessage());
+//					  e.getMessage();	
 					   } finally{
 						   try {
 							 if (rs != null) rs.close();
@@ -1815,6 +1957,7 @@
 								   if (ps != null) ps.close();
 							   } catch (SQLException e) {
 								   Log.severe(e.getMessage());
+//							    	e.getMessage();	
 							   }
 
 						   }
@@ -1846,11 +1989,13 @@
 						 ret = ps.executeUpdate();
 						 } catch (SQLException e) {
 							  Log.severe(e.getMessage());
+//                              e.getMessage();	
 						 } finally{
 							 try {
 							   if (ps != null) ps.close();
 							 } catch (SQLException e) {
 									Log.severe(e.getMessage());
+//								e.getMessage();	
 							 }
 					 }
 
@@ -1884,19 +2029,20 @@
 				}
 
 			} catch (SQLException e) {
-						// Send mail to moby admin
-//					   e.printStackTrace();
+//				e.getMessage();	
 				Log.severe(e.getMessage());
 					} finally{
 						try {
 							if (rs != null) rs.close();
 						} catch (SQLException e) {
 							Log.severe(e.getMessage());
+//							e.getMessage();	
 						}
 						try {
 							if (ps != null) ps.close();
 						} catch (SQLException e) {
 							Log.severe(e.getMessage());
+//							e.getMessage();	
 						}
 
 					}
@@ -1931,7 +2077,7 @@
 				}
 
 			} catch (SQLException e) {
-						// Send mail to moby admin
+						
 //					   e.printStackTrace();
 				Log.severe(e.getMessage());
 					} finally{
@@ -1939,15 +2085,17 @@
 							if (rs != null) rs.close();
 						} catch (SQLException e) {
 							Log.severe(e.getMessage());
+//							e.getMessage();	
 						}
 						try {
 							if (ps != null) ps.close();
 						} catch (SQLException e) {
 							Log.severe(e.getMessage());
+//							e.getMessage();	
 						}
 
 					}
-System.out.println("email = "+email);
+//System.out.println("email = "+email);
 			return email; 
 	
 		}
@@ -1976,7 +2124,7 @@
 					}
 
 				} catch (SQLException e) {
-							// Send mail to moby admin
+							
 //						   e.printStackTrace();
 					Log.severe(e.getMessage());
 						} finally{
@@ -1984,11 +2132,13 @@
 								if (rs != null) rs.close();
 							} catch (SQLException e) {
 								Log.severe(e.getMessage());
+//								e.getMessage();	
 							}
 							try {
 								if (ps != null) ps.close();
 							} catch (SQLException e) {
 								Log.severe(e.getMessage());
+//								e.getMessage();	
 							}
 
 						}

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Main.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/verifier/Main.java	2005/04/07 22:32:12	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Main.java	2005/04/14 16:14:21	1.3
@@ -1,98 +1,109 @@
 package org.biomoby.registry.rdfagent.verifier;
 
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import org.biomoby.registry.rdfagent.util.Constants;
-import org.biomoby.registry.rdfagent.util.DBConnector;
-import org.biomoby.registry.rdfagent.util.Log;
-import org.biomoby.registry.rdfagent.util.Report;
-import org.biomoby.registry.rdfagent.util.XMLBuilder;
-
+import org.biomoby.registry.rdfagent.util.*;
+import org.biomoby.registry.rdfagent.verifier.*;
 import com.hp.hpl.jena.rdf.model.Model;
+import java.util.Hashtable;
+import java.util.Enumeration;
+import com.hp.hpl.jena.vocabulary.*;
+import org.biomoby.registry.rdfagent.vocabulary.*;
+import java.util.logging.Logger;
+import java.util.Date;
+import java.util.Calendar;
 
 
 /**
- * @author developer
+ * @author Nina Opushneva
  *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
- * To enable and disable the creation of type comments go to
- * Window>Preferences>Java>Code Generation.
+ * 
  */
 public class Main {
 
 	public static void main(String[] args) {
 
+        
 		Log.start();
+			
 		String report = Constants.RDFagentHome+Constants.SV_REPORT_PATH;
-System.out.println("report_path = "+report);
 		Report.createFile(report);
-		String delfile = Constants.RDFagentHome+Constants.SV_DELFILE_PATH;	
-		Report.createFile(delfile);
-System.out.println("deleted_file_path = "+delfile);		
-        XMLBuilder.startServiceXml();
+	
 		
 		Date now = new Date();
 			
 		Report.doWrite("****************************************************************************************");
-		Report.doWrite("            START MOBY RDFAGENT REPORT          "+now.toString());
+		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 signURL = "";
-		  DataMngr.delServiceSetByURL(signURL);
+			
+			String delfile = Constants.RDFagentHome+Constants.SV_DELFILE_PATH;	
+			Report.createFile(delfile);	
+          
+//		  DataMngr.delServiceSetByURL(signURL);
 		  
-		   Calendar c = Calendar.getInstance();
+		   
 		   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{
-		   
-           serviceList = DataMngr.getServicesByURL(args[0]);
+/*		}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);           
         }
 
-        if (serviceList.isEmpty()){
-        	Log.warning("The list of services is empty");
-
-        }else{
 		Enumeration list = serviceList.keys();
-
 			  while (list.hasMoreElements()){
 				String ob = list.nextElement().toString();
 				String val  = serviceList.get(ob).toString();
-                String signURL = ob;
+                signURL = ob;
 				String servNames = val;
-				
-             
-               
+				              
 	                Model model = Communicator.getServiceRDF(servNames,signURL);
 				  
-                    if (model.isEmpty()){
-                 	  Log.info("Model " +signURL+" is empty");
-                    }else{
-       	
+                    if (model.isEmpty()){                 	
+                	  Log.info("Model " +signURL+" is empty");              	  
+                	 
+					 
+                    }else{                   	
+                      Report.add(" ");	
+       	              Report.add("List of the processed services:"); 
                       ServiceDescrParser sdParser = new ServiceDescrParser(model);
                       sdParser.getValidRDF(servNames,signURL);
+					 
 	                 }
-                 }
-			   
-		   }		 
-        exit();
+                 }			
+//		   }
+		if (args.length != 0){
+			
+//		  Report.send(signURL);	
+		}
+		   exit(signURL);
 	}
 
-    public static void exit(){
+    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("****************************************************************************************");
+
+		Report.send(signURL);	
         System.exit(0);
     }
 }




More information about the MOBY-guts mailing list