[MOBY-guts] biomoby commit

Eddie Kawas kawas at pub.open-bio.org
Fri Jul 29 23:05:46 UTC 2005


kawas
Fri Jul 29 18:19:05 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-serv12322/org/biomoby/registry/rdfagent/verifier

Modified Files:
	DataMngr.java 
Log Message:
not sure what i did - cvs says that there are differences. Probably bug fixes and formatting.

moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier DataMngr.java,1.10,1.11
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java	2005/07/28 15:24:41	1.10
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java	2005/07/29 22:19:05	1.11
@@ -24,2428 +24,2508 @@
 
 public class DataMngr {
 
-	/**
-	 * get the list of signatureURL from service_instance table
-	 * 
-	 * @return a Hashtable (signatureURL = string of servicenames for this URL
-	 *         separated by comma)
-	 * 
-	 *  
-	 */
-
-	public static Hashtable getServices(String file) {
-
-		Hashtable services = new Hashtable();
-
-		Connection con = DBConnector.getConnection();
-
-		final String sqlReq1 = "select servicename,signatureURL,authority_id from service_instance  order by signatureURL";
-
-		PreparedStatement ps = null;
-		ResultSet rs = null;
-
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			rs = ps.executeQuery();
-			String lastAddr = "";
-			StringBuffer servNames = new StringBuffer();
-			int lastID = -1;
-
-			while (rs.next()) {
-				String servName = rs.getString(1);
-				String rdfAddr = rs.getString(2);
-				int authorityID = rs.getInt(3);
-				if (rdfAddr == null) {
-					//TODO - make this code more efficient! - maybe perform one sql call instead of many
-					// update the signatureURL field using the service name and authority id
-					String bogusSigURL = "http://invalidURL123.com/author/"+ authorityID + "/" + servName +".xml";
-					String updateSQLString = "UPDATE service_instance " +
-											 "SET signatureURL='"+ bogusSigURL +"' " +
-											 "WHERE authority_id=" + authorityID + " and servicename='" + servName +"'";
-					PreparedStatement preparedStatement = null;
-					try {
-						Connection updateCon = DBConnector.getConnection();
-						preparedStatement = updateCon.prepareStatement(updateSQLString);
-						int resultSet = preparedStatement.executeUpdate();
-						Log.info(resultSet + ": Updated the signatureURL field of the authority with id #" + authorityID + " to be " + bogusSigURL+".");
-					} catch (SQLException e) {
-						Log.severe("Could not update SignatureURL field with a bogus signatureURL.\n" +e.getMessage());
-					}
-					
-				} else {
-					if (rdfAddr.equals(lastAddr)) {
-						servNames.append("," + servName);
-					} else {
-						if (servNames.length() > 0) {
-							services.put(lastAddr, servNames);
-							servNames = new StringBuffer();
-						}
-						servNames.append(servName);
-						lastAddr = rdfAddr;
-						Report.doSave(file, lastAddr);
-					}
-				}
-			}
-			services.put(lastAddr, servNames);
-
-		} 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();
-			}
-		}
-		//System.out.println("ListOFServices : "+services);
-
-		return services;
-	}
-
-	/**
-	 * get the list of services by signatureURL
-	 * 
-	 * @param signURL -
-	 *            URL of resource
-	 * @return a Hashtable (signatureURL = string of servicenames for this URL
-	 *         separated by comma)
-	 */
-
-	public static Hashtable getServicesByURL(String signURL) {
-
-		Hashtable services = new Hashtable();
-
-		Connection con = DBConnector.getConnection();
-
-		final String sqlReq1 = "select servicename,signatureURL from service_instance where signatureURL=?";
-
-		PreparedStatement ps = null;
-		ResultSet rs = null;
-
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setString(1, signURL);
-			rs = ps.executeQuery();
-			String lastAddr = "";
-			StringBuffer servNames = new StringBuffer();
-
-			while (rs.next()) {
-				String servName = rs.getString(1);
-				String rdfAddr = rs.getString(2);
-
-				if (rdfAddr.equals(lastAddr)) {
-					servNames.append("," + servName);
-				} else {
-					if (servNames.length() > 0) {
-						services.put(lastAddr, servNames);
-						servNames = new StringBuffer();
-					}
-					servNames.append(servName);
-					lastAddr = rdfAddr;
-				}
-			}
-			services.put(lastAddr, servNames);
-
-		} catch (SQLException e) {
-			//						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);
-
-		return services;
-	}
-
-	/**
-	 * 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 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 servInp -
-	 *            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
-	 */
-
-	public static void processService(Hashtable servSign, Hashtable servInp,
-			Hashtable servOut, String servname, String authURI, String signURL) {
-
-		Connection con = DBConnector.getConnection();
-		String servName = "";
-		String cat = "moby";
-		String url = "";
-		String email = "";
-		String desc = "";
-		String stype = "";
-		String authuri = "";
-		String authoritative = "";
-		String art = null;
-		String col_art = null;
-		String obt = null;
-		String nst = null;
-		String artsec = null;
-		String defsec = null;
-		String dtsec = null;
-
-		BigDecimal maxsec = null;
-		BigDecimal minsec = null;
-
-		String enumsec = null;
-		int colId = 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
-		int ret;
-		int servInstId = 0;
-		String signatureURL = "NNN";
-
-		// ************** Update service Signature ****************
-
-		Enumeration num = servSign.keys();
-
-		while (num.hasMoreElements()) {
-
-			Object ob = num.nextElement();
-			Object val = servSign.get(ob);
-			if (ob.equals("category")) {
-				cat = val.toString();
-			}
-			if (ob.equals("URL")) {
-				url = val.toString();
-			}
-			if (ob.equals("contact_email")) {
-				email = val.toString();
-			}
-			if (ob.equals("description")) {
-				desc = val.toString();
-			}
-			if (ob.equals("service_type_uri")) {
-				stype = val.toString();
-			}
-			if (ob.equals("authURI")) {
-				authuri = val.toString();
-			}
-			if (ob.equals("authoritative")) {
-				authoritative = val.toString();
-
-				if (authoritative.equals("non-authoritative")) {
-					authoritative = "0";
-				} else if (authoritative.equals("authoritative")) {
-					authoritative = "1";
-				}
-			}
-			if (ob.equals("servicename")) {
-				servName = val.toString();
-			}
-			if (ob.equals("signatureURL")) {
-				signatureURL = val.toString();
-			}
-
-		}
-
-		ServSignature signature = getServSignature(servname, signURL);
-		servInstId = signature.getServInstId();
-		//TODO make sure that the fields are updated
-		if (servInstId == 0) {
-
-			int authId = getAuthIdByAuthURI(authuri);
-
-			if (authId == 0) {
-				insIntoAuthority(authuri, email);
-				authId = getAuthIdByAuthURI(authuri);
-			}
-
-			if (signatureURL.equals("NNN")) {
-				ret = createSignature(servName, cat, stype, authId, url, email,
-						authoritative, desc, signURL);
-			} else {
-				ret = createSignature(servName, cat, stype, authId, url, email,
-						authoritative, desc, signatureURL);
-			}
-
-			if (ret == 1) {
-				String msg = "------The service instance  <" + servName
-						+ ">  was registered in the MOBYCENTRAL registry ";
-				Report.doWrite(msg);
-				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 }
-				 */
-				new_serv += 1;
-				servInstId = getServInstId(servName, authId);
-			}
-		} else {
-
-			if (!cat.equals(signature.getCategory())
-					|| !url.equals(signature.getUrl())
-					|| !email.equals(signature.getEmail())
-					|| !desc.equals(signature.getDescription())
-					|| !stype.equals(signature.getServiceType())
-					|| !authoritative.equals(signature.getAuthoritative())
-					|| !authuri.equals(authURI)) {
-
-			    //TODO
-			    Log.info("Updating the service '" + servName +"' since the RDF document has been modified.");
-				if (signatureURL.equals("NNN")) {
-				    Log.info("sig == NNN" + signURL);
-				    Log.info("<servName,cat,stype,authuri,url,email,desc,authoritative,signURL>=<"+servName+","+cat+","+stype+","+authuri+","+url+","+email+","+desc+","+authoritative+","+signURL+">");
-				    int res = updSign(servName, cat, stype, authuri, url,
-							email, desc, authoritative, signURL);
-					if (res == 1) {
-					    Report.doWrite("------The service instance<"+servName+"> was updated ");
-					    Report.add("------The service instance <"+servName+">was updated ");
-					} else {
-					    Report.doWrite("------The service instance<"+servName+"> was not updated");
-					    Report.add("------The service instance <"+servName+">was not updated ");
-					}
-
-				} else {
-				    Log.info("sig != NNN");
-					int res = updSign(servName, cat, stype, authuri, url,
-							email, desc, authoritative, signatureURL);
-					if (res == 1) {
-					    Report.doWrite("------The service instance <"+servName+"> was updated ");
-					    Report.add("------The service instance <"+servName+">was updated ");
-					} else {
-					    Report.doWrite("------The service instance <"+servName+"> was not updated ");
-					    Report.add("------The service instance <"+servName+">was not updated ");
-					}
-				}
-			}
-		}
-
-		// ************ 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);
-			Log.info("INPUTS <ob=val>:"+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) {
-					//                 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
-					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) {
-					delRow("simple_input", servInstId); // delete from
-					// simple_input table
-					dels = 1;
-				}
-			}
-			Hashtable simple = new Hashtable();
-			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(" ")) {
-						col_art = null;
-					}
-				} else if (ob1.equals("articleName")) {
-					art = simple.get(ob1).toString();
-					if (art.equals(" ")) {
-						art = null;
-					}
-				} else if (ob1.equals("article_name")) {
-					artsec = simple.get(ob1).toString();
-					if (artsec.equals(" ")) {
-						artsec = null;
-					}
-				} else if (ob1.equals("object_type_uri")) {
-					obt = simple.get(ob1).toString();
-				} else if (ob1.equals("namespace_type_uris")) {
-					nst = simple.get(ob1).toString();
-				} else if (ob1.equals("default")) {
-					defsec = simple.get(ob1).toString();
-				} else if (ob1.equals("datatype")) {
-					dtsec = simple.get(ob1).toString();
-				} else if (ob1.equals("max")) {
-					String maxsec_s = simple.get(ob1).toString();
-					try {
-						maxsec = new BigDecimal(maxsec_s);
-
-					} catch (NumberFormatException nx) {
-						Log.severe(nx.getMessage());
-						//				nx.getMessage();
-					}
-				} else if (ob1.equals("min")) {
-					String minsec_s = simple.get(ob1).toString();
-					try {
-						minsec = new BigDecimal(minsec_s);
-
-					} catch (NumberFormatException nx) {
-						Log.severe(nx.getMessage());
-						//	                  nx.getMessage();
-					}
-				} else if (ob1.equals("enum")) {
-					enumsec = simple.get(ob1).toString();
-				}
-			}
-
-			if (simcol.equals("colinp")) {
-				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")) {
-				insIntoSimpleInput(new Integer(servInstId), art, obt, nst, null);
-
-				art = null;
-				obt = null;
-				nst = null;
-			} else if (simcol.equals("secinp")) {
-
-				insIntoSecondary(servInstId, artsec, defsec, dtsec, maxsec,
-						minsec, enumsec);
-
-				artsec = null;
-				defsec = null;
-				dtsec = null;
-				maxsec = null;
-				minsec = null;
-				enumsec = null;
-			}
-
-			if (colId != 0) {
-				Report.doWrite("collection_input_id: " + colId);
-				//					Log.info("collection_input_id: "+colId);
-			}
-		}
-
-		Report.doWrite("service_instance_id: " + servInstId);
-		//		Log.info("service_instance_id: "+servInstId);
-
-		//  *********** add Output ***********************
-
-		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);
-			Log.info("OUTPUTS <ob=val>:"+ob+" = "+val );
-			if (simcol.equals("colout")) {
-				co += 1;
-				Report.doWrite(" ");
-				Report.add(" ");
-				Report.doWrite("Collection output " + co);
-				Report.add("Collection output " + co + ":");
-				if (delcout == 0) {
-					//					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
-					delcout = 1;
-				}
-			} else {
-				so += 1;
-				Report.doWrite(" ");
-				Report.add(" ");
-				Report.doWrite("Simple output " + so);
-				Report.add("Simple output " + so + ":");
-
-				//TODO bug #13 here?
-				if (delsout == 0) {
-					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(" ")) {
-						col_art = null;
-					}
-				}
-				if (ob1.equals("articleName")) {
-					art = simple.get(ob1).toString();
-					if (art.equals(" ")) {
-						art = null;
-					}
-				}
-				if (ob1.equals("object_type_uri")) {
-					obt = simple.get(ob1).toString();
-				}
-				if (ob1.equals("namespace_type_uris")) {
-					nst = simple.get(ob1).toString();
-				}
-			}
-
-			if (simcol.equals("colout")) {
-
-				insIntoCol("collection_output", col_art, servInstId); // insert
-				// the row
-				// into
-				// collection_input
-				// table
-
-				colOutId = new Integer(getCollectionId("collection_output",
-						"collection_output_id", servInstId));
-				insIntoSimpleOutput(null, art, obt, nst, colOutId);
-				art = null;
-				obt = null;
-				nst = null;
-			}
-			// TODO bug #11 here - fixed
-			if (simcol.equals("simout")) {
-				insIntoSimpleOutput(new Integer(servInstId), art, obt, nst,
-						null);
-				art = null;
-				obt=null;
-				nst=null;
-			}
-			if (colOutId != null) {
-				Report.doWrite("collection_output_id: " + colOutId);
-				//                  Log.info("collection_output_id: "+coloutId);
-			}
-		}
-		//	return serv;
-	}
-
-	/**
-	 * delete the service instance by service name and authority URI
-	 * 
-	 * @param servName
-	 *            the name of service which we want delete.
-	 * @param authURI
-	 *            the authority URI for service which we want delete.
-	 *  
-	 */
-
-	public static void delServByNameAndAuthURI(String servName, String authURI) {
-
-		int authId = getAuthIdByAuthURI(authURI);
-		int servInstId = getServInstId(servName, authId);
-
-		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
-		delRow("secondary_input", servInstId); //TODO - should this line be here?
-		delCollectionMember("input", servInstId);
-		delCollectionMember("output", servInstId);
-		delRow("collection_input", servInstId); // delete from table
-		// collection_input
-		delRow("collection_output", servInstId); // delete from table
-		// collection_output
-	}
-
-	/**
-	 * delete the service instance by service name and signature URL
-	 * 
-	 * @param servName
-	 *            the name of service which we want delete.
-	 * @param signURL
-	 *            the authority URI for service which we want delete.
-	 *  
-	 */
-
-	public static void delServByNameAndUrl(String servName, String signURL) {
-
-		int authId = getAuthIdByServNameAndSignURL(servName, signURL);
-		int servInstId = getServInstId(servName, authId);
-
-		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
-		delRow("secondary_input", servInstId); //TODO - should this line be here?
-		delCollectionMember("input", servInstId);
-		delCollectionMember("output", servInstId);
-		delRow("collection_input", servInstId); // delete from table
-		// collection_input
-		delRow("collection_output", servInstId); // delete from table
-		// collection_output
-	}
-
-	/**
-	 * delete set of the service instances with the same signatureURL by
-	 * signatureURL
-	 * 
-	 * @param signURL
-	 *            the name of service which we want delete.
-	 */
-
-	public static void delServiceSetByURL(String signURL) {
-
-		Connection con = DBConnector.getConnection();
-
-		final String sqlReq1 = "select service_instance_id,servicename,authority_id from service_instance where signatureURL = ?";
-		PreparedStatement ps = null;
-		ResultSet rs = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setString(1, signURL);
-			rs = ps.executeQuery();
-			Vector del_serv = new Vector();
-
-			while (rs.next()) {
-				int servInstId = rs.getInt(1);
-				String servName = rs.getString(2);
-				int authId = rs.getInt(3);
-
-				int rez = delSignature(servName, authId); // delete service from
-				// table
-				// service_instance
-				if (rez == 1) {
-					del_serv.addElement(servName);
-				}
-				delRow("secondary_input", servInstId); //TODO - should this line be here?
-				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
-			}
-
-			int del = del_serv.size();
-			if (del > 0) {
-				Report.doWrite("DELETED SERVICES: ");
-				Iterator i = del_serv.iterator();
-				int n = 1;
-				while (i.hasNext()) {
-					String delServ = i.next().toString();
-					Report.doWrite(n + ". " + delServ);
-					n += 1;
-				}
-			}
-
-		} catch (SQLException e) {
-			Log.severe(e.getMessage());
-			//			e.getMessage();
-		} finally {
-			try {
-				if (rs != null)
-					rs.close();
-			} catch (SQLException e) {
-			}
-			try {
-				if (ps != null)
-					ps.close();
-			} catch (SQLException e) {
-				Log.severe(e.getMessage());
-			}
-		}
-
-	}
-
-	/**
-	 * add the record about new service instance in the service_instance table
-	 * of mobycentral database
-	 * 
-	 * @param servName -
-	 *            the name of service instance the record was added for.
-	 * @param cat -
-	 *            the category of service instance.
-	 * @param servTypeURI -
-	 *            the service type URI of service instance.
-	 * @param authId -
-	 *            the authority Id of service instance.
-	 * @param url -
-	 *            the URL of service instance.
-	 * @param email -
-	 *            the contact e-Mail of service instance.
-	 * @param authoritative -
-	 *            the authoritative of service instance.
-	 * @param desc -
-	 *            the description of service instance.
-	 * @param signURL -
-	 *            the URL for RDF of service instance.
-	 * @return ret=1 if the record has added, and ret=-1 otherwise
-	 */
-
-	public static int createSignature(String servName, String cat,
-			String servTypeURI, int authId, String url, String email,
-			String authoritative, String desc, String signURL) {
-
-		Connection con = DBConnector.getConnection();
-
-		int ret = -1;
-
-		final String sqlReq1 = "insert into service_instance (servicename,category,service_type_uri,authority_id,url,contact_email,authoritative,description,signatureURL) values (?,?,?,?,?,?,?,?,?)";
-		PreparedStatement ps = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setString(1, servName);
-			ps.setString(2, cat);
-			ps.setString(3, servTypeURI);
-			ps.setInt(4, authId);
-			ps.setString(5, url);
-			ps.setString(6, email);
-			ps.setString(7, authoritative);
-			ps.setString(8, desc);
-			ps.setString(9, signURL);
-
-			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;
-	}
-
-	/**
-	 * update the service instance data in the service_instance table of
-	 * mobycentral database
-	 * 
-	 * @param servName
-	 *            the name of service instance the record was updated for.
-	 * @param cat
-	 *            the category of service instance.
-	 * @param stype
-	 *            the service type URI of service instance.
-	 * @param authuri
-	 *            the authority URI of service instance.
-	 * @param url
-	 *            the URL of service instance.
-	 * @param email
-	 *            the contact e-Mail of service instance.
-	 * @param authoritative
-	 *            the authoritative of service instance.
-	 * @param desc
-	 *            the description of service instance.
-	 * @param signURL
-	 *            the URL for RDF of service instance.
-	 * @return ret=1 if the record has updated, and ret=-1 otherwise
-	 */
-
-	public static int updSign(String servName, String cat, String stype,
-			String authuri, String url, String email, String desc,
-			String authoritative, String signURL) {
-
-		Connection con = DBConnector.getConnection();
-		int cnt = -1;
-		int ret = -1;
-		final String sqlReq = "select authority_id from authority where authority_uri = ?";
-		PreparedStatement ps = null;
-
-		final String sqlReq1 = "update service_instance set category = ?,service_type_uri = ?,url = ?,contact_email = ?,description = ?,authoritative = ?,signatureURL = ? where servicename = ? && authority_id = ?";
-		try {
-			ps = con.prepareStatement(sqlReq);
-			ps.setString(1, authuri);
-			ResultSet rs = ps.executeQuery();
-			while (rs.next()) {
-				cnt = rs.getInt(1);
-			}
-			if (cnt > -1) {
-				ps = con.prepareStatement(sqlReq1);
-				ps.setString(1, cat);
-				ps.setString(2, stype);
-				ps.setString(3, url);
-				ps.setString(4, email);
-				ps.setString(5, desc);
-				ps.setString(6, authoritative);
-				ps.setString(7, signURL);
-				ps.setString(8, servName);
-				ps.setInt(9, cnt);
-				ret = ps.executeUpdate();
-			}
-
-		} catch (SQLException e) {
-			//					e.getMessage();
-			Log.severe(e.getMessage());
-		} finally {
-			try {
-				if (ps != null)
-					ps.close();
-			} catch (SQLException e) {
-				Log.severe(e.getMessage());
-				//							e.getMessage();
-			}
-		}
-		return ret;
-	}
-
-	/**
-	 * add the record into the simple_input table
-	 * 
-	 * @param servInstId
-	 *            the Id of service instance the simple input was added for.
-	 * @param articleName
-	 *            the article name of the simple input.
-	 * @param objTypeUri
-	 *            the object type URI of the simple input.
-	 * @param nsTypeUris
-	 *            the string with set of the nameSpaces for this simple input.
-	 * @param colInpId
-	 *            the collection input Id if this simple input belongs to a
-	 *            collection, and blank otherwise.
-	 */
-
-	public static void insIntoSimpleInput(Integer servInstId,
-			String articleName, String objTypeUri, String nsTypeUris,
-			Integer colInpId) {
-
-		Connection con = DBConnector.getConnection();
-
-		int ret = -1;
-
-		final String sqlReq1 = "insert into simple_input (service_instance_id,article_name,object_type_uri,namespace_type_uris,collection_input_id) values (?,?,?,?,?)";
-
-		PreparedStatement ps = null;
-		try {
-			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);
-			if (colInpId != null) {
-				ps.setInt(5, colInpId.intValue());
-			} else {
-				ps.setNull(5, java.sql.Types.INTEGER);
-			}
-
-			ret = ps.executeUpdate();
-
-		} catch (SQLException e) {
-			//					   e.getMessage();
-			Log.severe(e.getMessage());
-		} finally {
-			try {
-				if (ps != null)
-					ps.close();
-			} catch (SQLException e) {
-				Log.severe(e.getMessage());
-				//							e.getMessage();
-			}
-		}
-	}
-
-	/**
-	 * update the record into the simple_input table
-	 * 
-	 * @param servInstId
-	 *            the Id of service instance the simple input was added for.
-	 * @param articleName
-	 *            the article name of the simple input.
-	 * @param objTypeUri
-	 *            the object type URI of the simple input.
-	 * @param nsTypeUris
-	 *            the string with set of the nameSpaces for this simple input.
-	 * @param colInpId
-	 *            the collection input Id if this simple input belongs to a
-	 *            collection, and blank otherwise.
-	 * @return ret=1 if the record has added, and ret=-1 otherwise
-	 */
-
-	public static int updateSimpleInput(int servInstId, String articleName,
-			String objTypeUri, String nsTypeUris, Integer colInpId, int minNum) {
-
-		Connection con = DBConnector.getConnection();
-
-		int ret = -1;
-
-		final String sqlReq1 = "update simple_input set service_instance_id=?,article_name=?,object_type_uri=?,namespace_type_uris=?,collection_input_id=? where simple_input_id=?";
-
-		PreparedStatement ps = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setInt(1, servInstId);
-			ps.setString(2, articleName);
-			ps.setString(3, objTypeUri);
-			ps.setString(4, nsTypeUris);
-			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) {
-			Log.severe(e.getMessage());
-			//				        	e.getMessage();
-		} finally {
-			try {
-				if (ps != null)
-					ps.close();
-			} catch (SQLException e) {
-				Log.severe(e.getMessage());
-				//							e.getMessage();
-			}
-		}
-		return ret;
-	}
-
-	/**
-	 * add the record about secondary input in the secondary_input table of
-	 * mobycentral database
-	 * 
-	 * @param servInstId
-	 *            the Id of service instance the secondary input was added for.
-	 * @param article_name
-	 *            the article name of the secondary input.
-	 * @param def
-	 *            the default value of the secondary input.
-	 * @param dataType
-	 *            the type of data of the secondary input.
-	 * @param max
-	 *            the maximum value of the secondary input
-	 * @param min
-	 *            the minimum value of the secondary input *
-	 * @param enumeration
-	 *            the enumeration value for the secondary input
-	 */
-
-	public static void insIntoSecondary(int servInstId, String article_name,
-			String def, String dataType, BigDecimal max, BigDecimal min,
-			String enumeration) {
-
-		Connection con = DBConnector.getConnection();
-
-		int ret = -1;
-
-		final String sqlReq1 = "insert into secondary_input (service_instance_id,article_name,default_value,maximum_value,minimum_value,enum_value,datatype) values (?,?,?,?,?,?,?)";
-
-		PreparedStatement ps = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setInt(1, servInstId);
-			ps.setString(2, article_name);
-			ps.setString(3, def);
-			ps.setBigDecimal(4, max);
-			ps.setBigDecimal(5, min);
-			ps.setString(6, enumeration);
-			ps.setString(7, dataType);
-
-			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();
-			}
-		}
-	}
-
-	/**
-	 * update the record into the secondary_input table
-	 * 
-	 * @param servInstId
-	 *            the Id of service instance the secondary input was added for.
-	 * @param article_name
-	 *            the article name of the secondary input.
-	 * @param def
-	 *            the default value of the secondary input.
-	 * @param dataType
-	 *            the type of data of the secondary input.
-	 * @param max
-	 *            the maximum value of the secondary input
-	 * @param min
-	 *            the minimum value of the secondary input
-	 * @param enumeration
-	 *            the enumeration value for the secondary input
-	 * @param minSecNum
-	 *            minimum free number for secondary_input_id
-	 */
-
-	public static void updateSec(int servInstId, String article_name,
-			String def, String dataType, BigDecimal max, BigDecimal min,
-			String enumeration, int minSecNum) {
-
-		Connection con = DBConnector.getConnection();
-
-		int ret = -1;
-
-		final String sqlReq1 = "update secondary_input set service_instance_id=?,article_name=?,default_value=?,maximum_value=?,minimum_value=?,enum_value=?,datatype=? where secondary_input_id=?";
-
-		PreparedStatement ps = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setInt(1, servInstId);
-			ps.setString(2, article_name);
-			ps.setString(3, def);
-			ps.setBigDecimal(4, max);
-			ps.setBigDecimal(5, min);
-			ps.setString(6, enumeration);
-			ps.setString(7, dataType);
-			ps.setInt(8, minSecNum);
-			ret = ps.executeUpdate();
-
-		} catch (SQLException e) {
-			//								e.getMessage();
-			Log.severe(e.getMessage());
-		} finally {
-			try {
-				if (ps != null)
-					ps.close();
-			} catch (SQLException e) {
-				//									e.getMessage();
-				Log.severe(e.getMessage());
-			}
-		}
-	}
-
-	/**
-	 * add the record into the simple_output table
-	 * 
-	 * @param servInstId
-	 *            the Id of service instance the simple output was added for.
-	 * @param articleName
-	 *            the article name of the simple output.
-	 * @param objTypeUri
-	 *            the object type URI of the simple output.
-	 * @param nsTypeUris
-	 *            the string with set of the nameSpaces for this simple output.
-	 * @param colOutId
-	 *            the collection input Id if this simple output belongs to a
-	 *            collection, and blank otherwise.
-	 */
-
-	public static void insIntoSimpleOutput(Integer servInstId,
-			String articleName, String objTypeUri, String nsTypeUris,
-			Integer colOutId) {
-
-		Connection con = DBConnector.getConnection();
-
-		int ret = -1;
-
-		final String sqlReq1 = "insert into simple_output (service_instance_id,article_name,object_type_uri,namespace_type_uris,collection_output_id) values (?,?,?,?,?)";
-
-		PreparedStatement ps = null;
-
-		try {
-			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);
-			if (colOutId != null) {
-				ps.setInt(5, colOutId.intValue());
-			} else {
-				ps.setNull(5, java.sql.Types.INTEGER);
-			}
-
-			ret = ps.executeUpdate();
-
-		} catch (SQLException e) {
-			//								e.getMessage();
-			Log.severe(e.getMessage());
-		} finally {
-			try {
-				if (ps != null)
-					ps.close();
-			} catch (SQLException e) {
-				Log.severe(e.getMessage());
-				//									e.getMessage();
-			}
-
-		}
-
-	}
-
-	/**
-	 * update the record into the simple_output table
-	 * 
-	 * @param servInstId
-	 *            the Id of service instance the simple output was added for.
-	 * @param articleName
-	 *            the article name of the simple output.
-	 * @param objTypeUri
-	 *            the object type URI of the simple output.
-	 * @param nsTypeUris
-	 *            the string with set of the nameSpaces for this simple output.
-	 * @param colOutId
-	 *            the collection input Id if this simple output belongs to a
-	 *            collection, and blank otherwise.
-	 * @return ret=1 if the record has added, and ret=-1 otherwise
-	 */
-
-	public static int updateSimpleOutput(int servInstId, String articleName,
-			String objTypeUri, String nsTypeUris, int colOutId, int minNum) {
-
-		Connection con = DBConnector.getConnection();
-
-		int ret = -1;
-
-		final String sqlReq1 = "update simple_output set service_instance_id=?,article_name=?,object_type_uri=?,namespace_type_uris=?,collection_output_id=? where simple_output_id=?";
-
-		PreparedStatement ps = null;
-
-		try {
-			ps = con.prepareStatement(sqlReq1);
-
-			ps.setInt(1, servInstId);
-			ps.setString(2, articleName);
-			ps.setString(3, objTypeUri);
-			ps.setString(4, nsTypeUris);
-			ps.setInt(5, colOutId);
-			ps.setInt(6, minNum);
-			ret = ps.executeUpdate();
-
-		} catch (SQLException e) {
-			//								e.getMessage();
-			Log.severe(e.getMessage());
-		} finally {
-			try {
-				if (ps != null)
-					ps.close();
-			} catch (SQLException e) {
-				Log.severe(e.getMessage());
-				//									e.getMessage();
-			}
-
-		}
-
-		return ret;
-	}
-
-	/**
-	 * get the number of errors for the given return code and URL of resource
-	 * 
-	 * @param signURL -
-	 *            the URL of resource was gotten the return code for.
-	 * @param errCode -
-	 *            the error code, connection was refused
-	 * @return Intrger number of error if was found in the database, zero
-	 *         otherwise
-	 */
-
-	public static int getServErrorNum(String signURL, int errCode) {
-
-		int num = 0;
-
-		Connection con = DBConnector.getConnection();
-
-		final String sqlReq1 = "select counter from service_validation where signatureURL = ? and error_code = ?";
-		PreparedStatement ps = null;
-		ResultSet rs = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setString(1, signURL);
-			ps.setInt(2, errCode);
-			rs = ps.executeQuery();
-
-			while (rs.next()) {
-				int cnt = rs.getInt(1);
-				num = cnt;
-
-			}
-
-		} catch (SQLException e) {
-			//			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();
-			}
-
-		}
-
-		return num;
-
-	}
-
-	/**
-	 * get the service signature data for service instance by the service name
-	 * and signatureURL
-	 * 
-	 * @param signURL -
-	 *            the URL of service RDF
-	 * @param servName -
-	 *            the name of service
-	 * @return carrier class ServSignature
-	 */
-
-	public static ServSignature getServSignature(String servName, String signURL) {
-
-		ServSignature signature = new ServSignature();
-
-		Connection con = DBConnector.getConnection();
-
-		final String sqlReq1 = "select service_instance_id,authority_id,category,service_type_uri,url,contact_email,authoritative,description from service_instance where servicename=? and signatureURL = ?";
-		PreparedStatement ps = null;
-		ResultSet rs = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setString(1, servName);
-			ps.setString(2, signURL);
-			rs = ps.executeQuery();
-
-			while (rs.next()) {
-				int servInstId = rs.getInt(1);
-				signature.setServInstId(servInstId);
-				int authId = rs.getInt(2);
-				signature.setAuthId(authId);
-				String category = rs.getString(3);
-				signature.setCategory(category);
-				String serviceType = rs.getString(4);
-				signature.setServiceType(serviceType);
-				String url = rs.getString(5);
-				signature.setUrl(url);
-				String email = rs.getString(6);
-				signature.setEmail(email);
-				String authoritative = rs.getString(7);
-				signature.setAuthoritative(authoritative);
-				String description = rs.getString(8);
-				signature.setDescription(description);
-				signature.setServiceName(servName);
-				signature.setSignatureURL(signURL);
-			}
-
-		} catch (SQLException e) {
-			//				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();
-			}
-
-		}
-
-		return signature;
-
-	}
-
-	/**
-	 * get the secondary input data by the secondary input Id
-	 * 
-	 * @param servInstId -
-	 *            the secondary input Id
-	 * @return carrier class Secondary
-	 */
-
-	public static Secondary getSecondary(int servInstId) {
-
-		Secondary second = new Secondary();
-
-		Connection con = DBConnector.getConnection();
-
-		final String sqlReq1 = "select default_value,maximum_value,minimum_value,enum_value,datatype,article_name from secondary_input where service_instance_id = ?";
-		PreparedStatement ps = null;
-		ResultSet rs = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setInt(1, servInstId);
-			rs = ps.executeQuery();
-			int open_sec = 0;
-			while (rs.next()) {
-				String defaultValue = rs.getString(1);
-				second.setDefaultValue(defaultValue);
-				BigDecimal maximumValue = rs.getBigDecimal(2);
-				second.setMaximumValue(maximumValue);
-				BigDecimal minimumValue = rs.getBigDecimal(3);
-				second.setMinimumValue(minimumValue);
-				String enumValue = rs.getString(4);
-				second.setEnumValue(enumValue);
-				String datatype = rs.getString(5);
-				second.setDatatype(datatype);
-				String articleName = rs.getString(6);
-				second.setArticleName(articleName);
-
-				XMLBuilder.buildSecondXml(second);
-			}
-
-		} catch (SQLException e) {
-			//					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();
-			}
-
-		}
-
-		return second;
-
-	}
-
-	/**
-	 * get the simple/collection output data by the service instance Id and
-	 * build xml representation
-	 * 
-	 * @param servInstId -
-	 *            the service instance Id
-	 */
-
-	public static void getSimpleCollectOutput(int servInstId) {
-
-		Connection con = DBConnector.getConnection();
-
-		final String sqlReq1 = "select article_name,namespace_type_uris,object_type_uri,collection_output_id from simple_output where service_instance_id = ?";
-		PreparedStatement ps = null;
-		ResultSet rs = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setInt(1, servInstId);
-			rs = ps.executeQuery();
-
-			while (rs.next()) {
-				String artName = rs.getString(1);
-				String nsType = rs.getString(2);
-				String objType = rs.getString(3);
-				//			   int colOutId = rs.getInt(4);
-				String type;
-				Integer colOutId = new Integer(rs.getInt(4));
-				if (colOutId == null) {
-					type = "so";
-				} else {
-					type = "co";
-				}
-
-				XMLBuilder.buildInpOutXml(artName, nsType, objType, type);
-			}
-		} catch (SQLException e) {
-			//		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();
-			}
-		}
-	}
-
-	/**
-	 * get the simple/collection input data by the service instance Id and build
-	 * xml representation
-	 * 
-	 * @param servInstId -
-	 *            the service instance Id
-	 */
-
-	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;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setInt(1, servInstId);
-			rs = ps.executeQuery();
-
-			while (rs.next()) {
-				String artName = rs.getString(1);
-				String nsType = rs.getString(2);
-				String objType = rs.getString(3);
-				String type;
-				//				   int colInpId = rs.getInt(4);
-				Integer colInpId = new Integer(rs.getInt(4));
-				if (colInpId == null) {
-					type = "si";
-				} else {
-					type = "ci";
-				}
-
-				XMLBuilder.buildInpOutXml(artName, nsType, objType, type);
-			}
-
-		} catch (SQLException e) {
-			//			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();
-			}
-
-		}
-	}
-
-	/**
-	 * update the counter for the given return code and URL of resource
-	 * 
-	 * @param signURL -
-	 *            the URL of resource was updated the counter for.
-	 * @param errCode -
-	 *            the error code was encreased the counter for.
-	 * @return Intrger ret=1 if the record was updated, ret=-1 otherwise
-	 */
-
-	public static int updErrCount(String signURL, int errCode) {
-
-		Connection con = DBConnector.getConnection();
-
-		int ret = -1;
-
-		final String sqlReq1 = "update service_validation set error_code = ?,counter=counter+1 where signatureURL = ?";
-		PreparedStatement ps = null;
-
-		try {
-			ps = con.prepareStatement(sqlReq1);
-
-			ps.setInt(1, errCode);
-			ps.setString(2, signURL);
-			ret = ps.executeUpdate();
-
-		} catch (SQLException e) {
-
-			Log.severe(e.getMessage());
-		} finally {
-			try {
-				if (ps != null)
-					ps.close();
-			} catch (SQLException e) {
-				Log.severe(e.getMessage());
-				//							e.getMessage();
-			}
-
-		}
-
-		return ret;
-	}
-
-	/**
-	 * add new record to the service_validation table of the mobycentral
-	 * database
-	 * 
-	 * @param signURL -
-	 *            the URL of resource the connection was refused for.
-	 * @param errCode -
-	 *            the error code, connection was refused
-	 * @return Intrger ret=1 if the record was added, ret=-1 otherwise
-	 */
-
-	public static int insErrCount(String signURL, int errCode) {
-
-		Connection con = DBConnector.getConnection();
-
-		int ret = -1;
-
-		final String sqlReq1 = "insert into service_validation (signatureURL,error_code,counter) values (?,?,1)";
-		PreparedStatement ps = null;
-
-		try {
-			ps = con.prepareStatement(sqlReq1);
-
-			ps.setString(1, signURL);
-			ps.setInt(2, errCode);
-			ret = ps.executeUpdate();
-
-		} catch (SQLException e) {
-			//							e.getMessage();
-			Log.severe(e.getMessage());
-		} finally {
-			try {
-				if (ps != null)
-					ps.close();
-			} catch (SQLException e) {
-				Log.severe(e.getMessage());
-				//								e.getMessage();
-			}
-
-		}
-
-		return ret;
-	}
-
-	/**
-	 * delete the record from service_validation table by signatureURL
-	 * 
-	 * @param signURL -
-	 *            the URL of resource the record was deleted for.
-	 * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise.
-	 */
-
-	public static int delServErrors(String signURL) {
-
-		Connection con = DBConnector.getConnection();
-		int ret = -1;
-		final String sqlReq1 = "delete from service_validation where signatureURL = ?";
-		PreparedStatement ps = null;
-
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setString(1, signURL);
-			ret = ps.executeUpdate();
-
-		} 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;
-
-	}
-
-	/**
-	 * get the service instance Id for the given service name and authority Id
-	 * 
-	 * @param servName -
-	 *            the name of service instance .
-	 * @param authId -
-	 *            the authority Id for the service instance.
-	 * @return Intrger service instance Id if was found in the database, zero
-	 *         otherwise
-	 */
-
-	public static int getServInstId(String servName, int authId) {
-
-		int servInsId = 0;
-
-		Connection con = DBConnector.getConnection();
-
-		final String sqlReq1 = "select service_instance_id from service_instance where servicename = ? && authority_id = ?";
-		PreparedStatement ps = null;
-		ResultSet rs = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setString(1, servName);
-			ps.setInt(2, authId);
-			rs = ps.executeQuery();
-
-			while (rs.next()) {
-				servInsId = rs.getInt(1);
-
-			}
-
-		} catch (SQLException e) {
-			Log.severe(e.getMessage());
-			//						e.getMessage();
-		} finally {
-			try {
-				if (rs != null)
-					rs.close();
-			} catch (SQLException e) {
-			}
-			try {
-				if (ps != null)
-					ps.close();
-			} catch (SQLException e) {
-				Log.severe(e.getMessage());
-				//									e.getMessage();
-			}
-
-		}
-
-		return servInsId;
-	}
-
-	/**
-	 * get the service instance Id for the given service name and signatureURL
-	 * 
-	 * @param servName -
-	 *            the name of service instance .
-	 * @param signURL -
-	 *            URL of resource for the service instance.
-	 * @return Intrger service instance Id if was found in the database, zero
-	 *         otherwise
-	 */
-
-	public static int getServInstId(String servName, String signURL) {
-
-		int servInsId = 0;
-
-		Connection con = DBConnector.getConnection();
-
-		final String sqlReq1 = "select service_instance_id from service_instance where servicename = ? && signatureURL = ?";
-		PreparedStatement ps = null;
-		ResultSet rs = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setString(1, servName);
-			ps.setString(2, signURL);
-			rs = ps.executeQuery();
-
-			while (rs.next()) {
-				servInsId = rs.getInt(1);
-
-			}
-
-		} catch (SQLException e) {
-			Log.severe(e.getMessage());
-			//							e.getMessage();
-		} finally {
-			try {
-				if (rs != null)
-					rs.close();
-			} catch (SQLException e) {
-			}
-			try {
-				if (ps != null)
-					ps.close();
-			} catch (SQLException e) {
-				Log.severe(e.getMessage());
-				//										e.getMessage();
-			}
-
-		}
-
-		return servInsId;
-	}
-
-	/**
-	 * get the set of services for the given URL of resource by signatureURL
-	 * 
-	 * @param signURL -
-	 *            the URL of resource .
-	 * @return String set of the services which was found in the database, empty
-	 *         string otherwise
-	 */
-
-	public static String getServListByURL(String signURL) {
-
-		StringBuffer servList = new StringBuffer();
-
-		Connection con = DBConnector.getConnection();
-
-		final String sqlReq1 = "select servicename from service_instance where signatureURL = ?";
-		PreparedStatement ps = null;
-		ResultSet rs = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setString(1, signURL);
-			rs = ps.executeQuery();
-
-			while (rs.next()) {
-				String servName = rs.getString(1);
-				servList.append(servName + ",");
-			}
-
-		} catch (SQLException e) {
-			Log.severe(e.getMessage());
-			//							e.getMessage();
-		} finally {
-			try {
-				if (rs != null)
-					rs.close();
-			} catch (SQLException e) {
-			}
-			try {
-				if (ps != null)
-					ps.close();
-			} catch (SQLException e) {
-				Log.severe(e.getMessage());
-				//										e.getMessage();
-			}
-
-		}
-
-		return servList.toString();
-	}
-
-	/**
-	 * delete a record from given table by a service instance Id (the metod is
-	 * working for simple_input/output, collection input/output tables)
-	 * 
-	 * @param servInstId -
-	 *            the service instance Id.
-	 * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise.
-	 */
-
-	public static int delRow(String tableName, int servInstId) {
-
-		Connection con = DBConnector.getConnection();
-
-		int ret = -1;
-
-		final String sqlReq1 = "delete from " + tableName
-				+ " where service_instance_id = ?";
-
-		PreparedStatement ps = null;
-
-		try {
-			ps = con.prepareStatement(sqlReq1);
-
-			ps.setInt(1, servInstId);
-
-			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;
-	}
-
-	/**
-	 * delete a record from simple table by a service instance Id and
-	 * collection_input_id (the metod is working for simple_input/output,
-	 * collection input/output tables)
-	 * 
-	 * @param servInstId -
-	 *            the service instance Id.
-	 */
-
-	public static void delCollectionMember(String inout, int servInstId) {
-
-		Connection con = DBConnector.getConnection();
-
-		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 {
-					ps1 = con.prepareStatement(sqlReq);
-					//							    ps.setInt(1, servInstId);
-					ps1.executeUpdate();
-				} catch (SQLException e) {
-					Log.severe(e.getMessage());
-				} finally {
-					try {
-						if (ps1 != null)
-							ps1.close();
-					} catch (SQLException e) {
-						Log.severe(e.getMessage());
-					}
-				}
-			}
-
-		} 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
-	 * 
-	 * @param servName -
-	 *            the service instance name.
-	 * @param authId -
-	 *            the id of the authority
-	 * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise.
-	 */
-
-	public static int delSignature(String servName, int authId) {
-
-		Connection con = DBConnector.getConnection();
-
-		int ret = -1;
-
-		//			if (authId == 0){
-		final String sqlReq1 = "delete from service_instance where servicename= ? and authority_id = ?";
-		PreparedStatement ps = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setString(1, servName);
-			ps.setInt(2, authId);
-			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;
-	}
-
-	/**
-	 * get the collection Id from collection_input or collection_output table by
-	 * the service_instance_id
-	 * 
-	 * @param table -
-	 *            the collection_input or collection_output table
-	 * @param field -
-	 *            "collection_input_id" (for collection_input table) and
-	 *            "collection_output_id" (for collection_output table)
-	 * @param servInstId -
-	 *            Id of service instance
-	 * @return Integer collection Id if was found, zero otherwise.
-	 */
-
-	public static int getCollectionId(String table, String field, int servInstId) {
-
-		int colId = 0;
-
-		Connection con = DBConnector.getConnection();
-
-		final String sqlReq1 = "select "
-				+ field
-				+ " from "
-				+ table
-				+ " where service_instance_id = ? order by service_instance_id,"
-				+ field + " ASC";
-		PreparedStatement ps = null;
-		ResultSet rs = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setInt(1, servInstId);
-			rs = ps.executeQuery();
-
-			while (rs.next()) {
-				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();
-			}
-
-		}
-
-		return colId;
-
-	}
-
-	/**
-	 * add new record into the collection_input or collection_output table
-	 * 
-	 * @param table -
-	 *            the collection_input or collection_output table
-	 * @param artName -
-	 *            the artical name of the collection_input or collection_output
-	 * @param servInstId -
-	 *            Id of service instance
-	 * @return Intrger ret=1 if the record was added, ret=-1 otherwise
-	 */
-
-	public static int insIntoCol(String table, String artName, int servInstId) {
-
-		Connection con = DBConnector.getConnection();
-
-		int ret = -1;
-
-		final String sqlReq1 = "insert into " + table
-				+ " (article_name,service_instance_id) values (?,?)";
-		PreparedStatement ps = null;
-
-		try {
-			ps = con.prepareStatement(sqlReq1);
-
-			ps.setString(1, artName);
-			ps.setInt(2, servInstId);
-			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;
-	}
-
-	/**
-	 * update record into the collection_input or collection_output table
-	 * 
-	 * @param table -
-	 *            the collection_input or collection_output table
-	 * @param key_field -
-	 *            collection_input_id for collection_input table,
-	 *            collection_output_id for collection_output table;
-	 * @param artName -
-	 *            the artical name of the collection_input or collection_output
-	 * @param servInstId -
-	 *            Id of service instance
-	 * @return Intrger ret=1 if the record was added, ret=-1 otherwise
-	 */
-
-	public static int updateCol(String table, String key_field, String artName,
-			int servInstId, int minNum) {
-
-		Connection con = DBConnector.getConnection();
-
-		int ret = -1;
-
-		final String sqlReq1 = "update " + table
-				+ " set article_name=?,service_instance_id=? where "
-				+ key_field + " =?";
-
-		PreparedStatement ps = null;
-
-		try {
-			ps = con.prepareStatement(sqlReq1);
-
-			ps.setString(1, artName);
-			ps.setInt(2, servInstId);
-			ps.setInt(3, minNum);
-			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;
-	}
-
-	/**
-	 * get the service authority URI from authority table by the servicename
-	 * 
-	 * @param servName -
-	 *            the name of service
-	 * @return String authority URI if was found, empty string otherwise.
-	 */
-
-	public static String getServAuthURI(String servName) {
-
-		Connection con = DBConnector.getConnection();
-
-		String authURI = "";
-
-		final String sqlReq1 = "select authority_uri from service_instance si,authority a where si.authority_id=a.authority_id and si.servicename=?";
-		;
-		PreparedStatement ps = null;
-		ResultSet rs = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setString(1, servName);
-			rs = ps.executeQuery();
-
-			while (rs.next()) {
-				authURI = rs.getString(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();
-			}
-
-		}
-
-		return authURI;
-
-	}
-
-	/**
-	 * get the service authority Id from service_instance table by the
-	 * servicename and signatureURL
-	 * 
-	 * @param serviceName -
-	 *            the name of service
-	 * @param signURL -
-	 *            the signatureURL for the given service
-	 * @return int authority Id if was found, zero otherwise.
-	 */
-
-	public static int getAuthIdByServNameAndSignURL(String serviceName,
-			String signURL) {
-
-		int authId = 0;
-
-		Connection con = DBConnector.getConnection();
-
-		final String sqlReq1 = "select authority_id from service_instance where servicename = ? and signatureURL = ?";
-		PreparedStatement ps = null;
-		ResultSet rs = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setString(1, serviceName);
-			ps.setString(2, signURL);
-			rs = ps.executeQuery();
-
-			while (rs.next()) {
-				authId = rs.getInt(1);
-
-			}
-
-		} catch (SQLException e) {
-			Log.severe(e.getMessage());
-			//					  e.getMessage();
-		} finally {
-			try {
-				if (rs != null)
-					rs.close();
-			} catch (SQLException e) {
-			}
-			try {
-				if (ps != null)
-					ps.close();
-			} catch (SQLException e) {
-				Log.severe(e.getMessage());
-				//							    	e.getMessage();
-			}
-
-		}
-
-		return authId;
-	}
-
-	/**
-	 * add new record to the authority table
-	 * 
-	 * @param authURI -
-	 *            the authority URI
-	 * @param email -
-	 *            the contact e-Mail
-	 * @return Intrger ret=1 if the record was added, ret=-1 otherwise
-	 */
-
-	public static int insIntoAuthority(String authURI, String email) {
-
-		Connection con = DBConnector.getConnection();
-
-		int ret = -1;
-
-		final String sqlReq1 = "insert into authority (authority_common_name,authority_uri,contact_email) values (null,?,?)";
-		PreparedStatement ps = null;
-
-		try {
-			ps = con.prepareStatement(sqlReq1);
-
-			ps.setString(1, authURI);
-			ps.setString(2, email);
-			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;
-	}
-
-	/**
-	 * get the service authority Id from authority table by the authority URI
-	 * 
-	 * @param authURI -
-	 *            the authority URI
-	 * @return int authority Id if was found, zero otherwise.
-	 */
-
-	public static int getAuthIdByAuthURI(String authURI) {
-
-		int authId = 0;
-
-		Connection con = DBConnector.getConnection();
-
-		final String sqlReq1 = "select authority_id from authority where authority_uri = ?";
-		PreparedStatement ps = null;
-		ResultSet rs = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setString(1, authURI);
-
-			rs = ps.executeQuery();
-
-			while (rs.next()) {
-				authId = rs.getInt(1);
-			}
-
-		} catch (SQLException e) {
-			//				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();
-			}
-
-		}
-
-		return authId;
-
-	}
-
-	/**
-	 * get the contact e-Mail from service_instance table by the servicename
-	 * 
-	 * @param signURL -
-	 *            the URL of a resource
-	 * @return String contact e-Mail if was found, empty string otherwise.
-	 */
-
-	public static String getContactEmail(String signURL) {
-
-		String email = "";
-
-		Connection con = DBConnector.getConnection();
-
-		final String sqlReq1 = "select contact_email from service_instance where signatureURL = ? ";
-		PreparedStatement ps = null;
-		ResultSet rs = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			ps.setString(1, signURL);
-			rs = ps.executeQuery();
-
-			while (rs.next()) {
-				String cnt = rs.getString(1);
-				email = cnt;
-
-			}
-
-		} catch (SQLException e) {
-
-			//					   e.printStackTrace();
-			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();
-			}
-
-		}
-		//System.out.println("email = "+email);
-		return email;
-
-	}
-
-	/**
-	 * 
-	 * gets the min number of records with service instance id = 0
-	 * 
-	 * @param table
-	 * @param key_field
-	 * @return the number of records
-	 */
-
-	public static int getMinFreeNumber(String table, String key_field) {
-
-		int num = 0;
-
-		Connection con = DBConnector.getConnection();
-
-		final String sqlReq1 = "select min(" + key_field + ") from " + table
-				+ " where service_instance_id = 0 order by " + key_field;
-
-		PreparedStatement ps = null;
-		ResultSet rs = null;
-		try {
-			ps = con.prepareStatement(sqlReq1);
-			rs = ps.executeQuery();
-
-			while (rs.next()) {
-				num = rs.getInt(1);
-			}
-
-		} catch (SQLException e) {
-
-			//						   e.printStackTrace();
-			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();
-			}
+    /**
+     * get the list of signatureURL from service_instance table
+     * 
+     * @return a Hashtable (signatureURL = string of servicenames for this URL
+     *         separated by comma)
+     * 
+     *  
+     */
+
+    public static Hashtable getServices(String file) {
+
+        Hashtable services = new Hashtable();
+
+        Connection con = DBConnector.getConnection();
+
+        final String sqlReq1 = "select servicename,signatureURL,authority_id from service_instance  order by signatureURL";
+
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            rs = ps.executeQuery();
+            String lastAddr = "";
+            StringBuffer servNames = new StringBuffer();
+            int lastID = -1;
+
+            while (rs.next()) {
+                String servName = rs.getString(1);
+                String rdfAddr = rs.getString(2);
+                int authorityID = rs.getInt(3); // value will never be null, so
+                                                // wasNull() not necessary
+                if (rdfAddr == null) {
+                    //TODO - make this code more efficient! - maybe perform one
+                    // sql call instead of many
+                    // update the signatureURL field using the service name and
+                    // authority id
+                    String bogusSigURL = "http://invalidURL123.com/author/"
+                            + authorityID + "/" + servName + ".xml";
+                    String updateSQLString = "UPDATE service_instance "
+                            + "SET signatureURL='" + bogusSigURL + "' "
+                            + "WHERE authority_id=" + authorityID
+                            + " and servicename='" + servName + "'";
+                    PreparedStatement preparedStatement = null;
+                    try {
+                        Connection updateCon = DBConnector.getConnection();
+                        preparedStatement = updateCon
+                                .prepareStatement(updateSQLString);
+                        int resultSet = preparedStatement.executeUpdate();
+                        Log
+                                .info(resultSet
+                                        + ": Updated the signatureURL field of the authority with id #"
+                                        + authorityID + " to be " + bogusSigURL
+                                        + ".");
+                    } catch (SQLException e) {
+                        Log
+                                .severe("Could not update SignatureURL field with a bogus signatureURL.\n"
+                                        + e.getMessage());
+                    }
+
+                } else {
+                    if (rdfAddr.equals(lastAddr)) {
+                        servNames.append("," + servName);
+                    } else {
+                        if (servNames.length() > 0) {
+                            services.put(lastAddr, servNames);
+                            servNames = new StringBuffer();
+                        }
+                        servNames.append(servName);
+                        lastAddr = rdfAddr;
+                        Report.doSave(file, lastAddr);
+                    }
+                }
+            }
+            services.put(lastAddr, servNames);
+
+        } 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();
+            }
+        }
+        //System.out.println("ListOFServices : "+services);
+
+        return services;
+    }
+
+    /**
+     * get the list of services by signatureURL
+     * 
+     * @param signURL -
+     *            URL of resource
+     * @return a Hashtable (signatureURL = string of servicenames for this URL
+     *         separated by comma)
+     */
+
+    public static Hashtable getServicesByURL(String signURL) {
+
+        Hashtable services = new Hashtable();
+
+        Connection con = DBConnector.getConnection();
+
+        final String sqlReq1 = "select servicename,signatureURL from service_instance where signatureURL=?";
+
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setString(1, signURL);
+            rs = ps.executeQuery();
+            String lastAddr = "";
+            StringBuffer servNames = new StringBuffer();
+
+            while (rs.next()) {
+                String servName = rs.getString(1);
+                String rdfAddr = rs.getString(2);
+
+                if (rdfAddr.equals(lastAddr)) {
+                    servNames.append("," + servName);
+                } else {
+                    if (servNames.length() > 0) {
+                        services.put(lastAddr, servNames);
+                        servNames = new StringBuffer();
+                    }
+                    servNames.append(servName);
+                    lastAddr = rdfAddr;
+                }
+            }
+            services.put(lastAddr, servNames);
+
+        } catch (SQLException e) {
+            //						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);
+
+        return services;
+    }
+
+    /**
+     * 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 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 servInp -
+     *            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
+     */
+
+    public static void processService(Hashtable servSign, Hashtable servInp,
+            Hashtable servOut, String servname, String authURI, String signURL) {
+
+        Connection con = DBConnector.getConnection();
+        String servName = "";
+        String cat = "moby";
+        String url = "";
+        String email = "";
+        String desc = "";
+        String stype = "";
+        String authuri = "";
+        String authoritative = "";
+        String art = null;
+        String col_art = null;
+        String obt = null;
+        String nst = null;
+        String artsec = null;
+        String defsec = null;
+        String dtsec = null;
+
+        BigDecimal maxsec = null;
+        BigDecimal minsec = null;
+
+        String enumsec = null;
+        int colId = 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
+        int ret;
+        int servInstId = 0;
+        String signatureURL = "NNN";
+
+        // ************** Update service Signature ****************
+
+        Enumeration num = servSign.keys();
+
+        while (num.hasMoreElements()) {
+
+            Object ob = num.nextElement();
+            Object val = servSign.get(ob);
+            if (ob.equals("category")) {
+                cat = val.toString();
+            } else if (ob.equals("URL")) {
+                url = val.toString();
+            } else if (ob.equals("contact_email")) {
+                email = val.toString();
+            } else if (ob.equals("description")) {
+                desc = val.toString();
+            } else if (ob.equals("service_type_uri")) {
+                stype = val.toString();
+            } else if (ob.equals("authURI")) {
+                authuri = val.toString();
+            } else if (ob.equals("authoritative")) {
+                authoritative = val.toString();
+
+                if (authoritative.equals("non-authoritative")) {
+                    authoritative = "0";
+                } else if (authoritative.equals("authoritative")) {
+                    authoritative = "1";
+                }
+            } else if (ob.equals("servicename")) {
+                servName = val.toString();
+            } else if (ob.equals("signatureURL")) {
+                signatureURL = val.toString();
+            }
+
+        }
+
+        ServSignature signature = getServSignature(servname, signURL);
+        servInstId = signature.getServInstId();
+        //TODO make sure that the fields are updated
+        if (servInstId == 0) {
+
+            int authId = getAuthIdByAuthURI(authuri);
+
+            if (authId == 0) {
+                insIntoAuthority(authuri, email);
+                authId = getAuthIdByAuthURI(authuri);
+            }
+
+            if (signatureURL.equals("NNN")) {
+                ret = createSignature(servName, cat, stype, authId, url, email,
+                        authoritative, desc, signURL);
+            } else {
+                ret = createSignature(servName, cat, stype, authId, url, email,
+                        authoritative, desc, signatureURL);
+            }
+
+            if (ret == 1) {
+                String msg = "------The service instance  <" + servName
+                        + ">  was registered in the MOBYCENTRAL registry ";
+                Report.doWrite(msg);
+                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 }
+                 */
+                new_serv += 1;
+                servInstId = getServInstId(servName, authId);
+            }
+        } else {
+
+            if (!cat.equals(signature.getCategory())
+                    || !url.equals(signature.getUrl())
+                    || !email.equals(signature.getEmail())
+                    || !desc.equals(signature.getDescription())
+                    || !stype.equals(signature.getServiceType())
+                    || !authoritative.equals(signature.getAuthoritative())
+                    || !authuri.equals(authURI)) {
+
+                //TODO
+                Log.info("Updating the service '" + servName
+                        + "' since the RDF document has been modified.");
+                if (signatureURL.equals("NNN")) {
+                    Log.info("sig == NNN" + signURL);
+                    Log
+                            .info("<servName,cat,stype,authuri,url,email,desc,authoritative,signURL>=<"
+                                    + servName
+                                    + ","
+                                    + cat
+                                    + ","
+                                    + stype
+                                    + ","
+                                    + authuri
+                                    + ","
+                                    + url
+                                    + ","
+                                    + email
+                                    + ","
+                                    + desc
+                                    + ","
+                                    + authoritative
+                                    + ","
+                                    + signURL + ">");
+                    int res = updSign(servName, cat, stype, authuri, url,
+                            email, desc, authoritative, signURL);
+                    if (res == 1) {
+                        Report.doWrite("------The service instance<" + servName
+                                + "> was updated ");
+                        Report.add("------The service instance <" + servName
+                                + ">was updated ");
+                    } else {
+                        Report.doWrite("------The service instance<" + servName
+                                + "> was not updated");
+                        Report.add("------The service instance <" + servName
+                                + ">was not updated ");
+                    }
+
+                } else {
+                    Log.info("sig != NNN");
+                    int res = updSign(servName, cat, stype, authuri, url,
+                            email, desc, authoritative, signatureURL);
+                    if (res == 1) {
+                        Report.doWrite("------The service instance <"
+                                + servName + "> was updated ");
+                        Report.add("------The service instance <" + servName
+                                + ">was updated ");
+                    } else {
+                        Report.doWrite("------The service instance <"
+                                + servName + "> was not updated ");
+                        Report.add("------The service instance <" + servName
+                                + ">was not updated ");
+                    }
+                }
+            }
+        }
+
+        // ************ add Input *********************
+
+        Enumeration num1 = servInp.keys();
+        int dels = 0;
+        int delc = 0;
+        int delsec = 0;
+        int si = 0;
+        int ci = 0;
+        int sci = 0;
+
+        /* if there are no inputs, delete all from mobycentral */
+        if (servInp.size() == 0) {
+            //make sure that there are no inputs in the db (simples, secondary
+            // or collection)
+            if (delRow("secondary_input", servInstId) == 1)
+                delsec = 1;
+            delCollectionMember("input", servInstId);
+            if (delRow("collection_input", servInstId) == 1)
+                delc = 1;
+            if (delRow("simple_input", servInstId) == 1)
+                dels = 1;
+        }
+        if (!servInp.containsKey("siminp1")) {
+            if (delRow("simple_input", servInstId) == 1)
+                dels = 1;            
+        }
+        if (!servInp.containsKey("colinp1")) {
+            delCollectionMember("input", servInstId);
+            if (delRow("collection_input", servInstId) == 1)
+                delc = 1;            
+        }
+        /*
+         * going to remove any secondaries not in the hash - quick hack to
+         * bug#29
+         */
+        if (!servInp.containsKey("secinp1")) {
+            if (delRow("secondary_input", servInstId) == 1)
+                delsec = 1;
+        }
+        while (num1.hasMoreElements()) {
+            Object ob = num1.nextElement();
+            Object val = servInp.get(ob);
+            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);
+                    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) {
+                    //                 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
+                    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) {
+                    delRow("simple_input", servInstId); // delete from
+                    // simple_input table
+                    dels = 1;
+                }
+            }
+            Hashtable simple = new Hashtable();
+            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(" ")) {
+                        col_art = null;
+                    }
+                } else if (ob1.equals("articleName")) {
+                    art = simple.get(ob1).toString();
+                    if (art.equals(" ")) {
+                        art = null;
+                    }
+                } else if (ob1.equals("article_name")) {
+                    artsec = simple.get(ob1).toString();
+                    if (artsec.equals(" ")) {
+                        artsec = null;
+                    }
+                } else if (ob1.equals("object_type_uri")) {
+                    obt = simple.get(ob1).toString();
+                } else if (ob1.equals("namespace_type_uris")) {
+                    nst = simple.get(ob1).toString();
+                } else if (ob1.equals("default")) {
+                    defsec = simple.get(ob1).toString();
+                } else if (ob1.equals("datatype")) {
+                    dtsec = simple.get(ob1).toString();
+                } else if (ob1.equals("max")) {
+                    String maxsec_s = simple.get(ob1).toString();
+                    try {
+                        maxsec = new BigDecimal(maxsec_s);
+
+                    } catch (NumberFormatException nx) {
+                        Log.severe(nx.getMessage());
+                        //				nx.getMessage();
+                    }
+                } else if (ob1.equals("min")) {
+                    String minsec_s = simple.get(ob1).toString();
+                    try {
+                        minsec = new BigDecimal(minsec_s);
+
+                    } catch (NumberFormatException nx) {
+                        Log.severe(nx.getMessage());
+                        //	                  nx.getMessage();
+                    }
+                } else if (ob1.equals("enum")) {
+                    enumsec = simple.get(ob1).toString();
+                }
+            }
+
+            if (simcol.equals("colinp")) {
+                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")) {
+                insIntoSimpleInput(new Integer(servInstId), art, obt, nst, null);
+
+                art = null;
+                obt = null;
+                nst = null;
+            } else if (simcol.equals("secinp")) {
+
+                insIntoSecondary(servInstId, artsec, defsec, dtsec, maxsec,
+                        minsec, enumsec);
+
+                artsec = null;
+                defsec = null;
+                dtsec = null;
+                maxsec = null;
+                minsec = null;
+                enumsec = null;
+            }
+
+            if (colId != 0) {
+                Report.doWrite("collection_input_id: " + colId);
+                //					Log.info("collection_input_id: "+colId);
+            }
+        }
+
+        Report.doWrite("service_instance_id: " + servInstId);
+        //		Log.info("service_instance_id: "+servInstId);
+
+        //  *********** add Output ***********************
+
+        Enumeration numout = servOut.keys();
+        int delsout = 0;
+        int delcout = 0;
+        int so = 0;
+        int co = 0;
+        if (servOut.size() == 0) {
+            //make sure that there are no outputs in the db (simples or
+            // collection)
+            delCollectionMember("output", servInstId);
+            if (delRow("collection_output", servInstId) == 1)
+                delcout = 1;
+            if (delRow("simple_output", servInstId) == 1)
+                delsout = 1;
+            Report.doWrite("Removed all outputs.");
+            Log.info("Removed all outputs.");
+        }
+        if (!servOut.containsKey("colout1")) { // using simout1 because counting starts at 1
+            delCollectionMember("output", servInstId);
+            if (delRow("collection_output", servInstId) == 1)
+                delcout = 1;
+        }
+        if (!servOut.containsKey("simout1")) { // using simout1 because counting starts at 1
+            if (delRow("simple_output", servInstId) == 1)
+                delsout = 1;
+        }
+        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) {
+                    //					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
+                    delcout = 1;
+                }
+            } else {
+                so += 1;
+                Report.doWrite(" ");
+                Report.add(" ");
+                Report.doWrite("Simple output " + so);
+                Report.add("Simple output " + so + ":");
+
+                //TODO bug #13 here?
+                if (delsout == 0) {
+                    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(" ")) {
+                        col_art = null;
+                    }
+                }
+                if (ob1.equals("articleName")) {
+                    art = simple.get(ob1).toString();
+                    if (art.equals(" ")) {
+                        art = null;
+                    }
+                }
+                if (ob1.equals("object_type_uri")) {
+                    obt = simple.get(ob1).toString();
+                }
+                if (ob1.equals("namespace_type_uris")) {
+                    nst = simple.get(ob1).toString();
+                }
+            }
+
+            if (simcol.equals("colout")) {
+
+                insIntoCol("collection_output", col_art, servInstId); // insert
+                // the row
+                // into
+                // collection_input
+                // table
+
+                colOutId = new Integer(getCollectionId("collection_output",
+                        "collection_output_id", servInstId));
+                insIntoSimpleOutput(null, art, obt, nst, colOutId);
+                art = null;
+                obt = null;
+                nst = null;
+            }
+            // TODO bug #11 here - fixed
+            if (simcol.equals("simout")) {
+                insIntoSimpleOutput(new Integer(servInstId), art, obt, nst,
+                        null);
+                art = null;
+                obt = null;
+                nst = null;
+            }
+            if (colOutId != null) {
+                Report.doWrite("collection_output_id: " + colOutId);
+                //                  Log.info("collection_output_id: "+coloutId);
+            }
+        }
+        //	return serv;
+    }
+
+    /**
+     * delete the service instance by service name and authority URI
+     * 
+     * @param servName
+     *            the name of service which we want delete.
+     * @param authURI
+     *            the authority URI for service which we want delete.
+     *  
+     */
+
+    public static void delServByNameAndAuthURI(String servName, String authURI) {
+
+        int authId = getAuthIdByAuthURI(authURI);
+        int servInstId = getServInstId(servName, authId);
+
+        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
+        delRow("secondary_input", servInstId); //TODO - should this line be
+                                               // here?
+        delCollectionMember("input", servInstId);
+        delCollectionMember("output", servInstId);
+        delRow("collection_input", servInstId); // delete from table
+        // collection_input
+        delRow("collection_output", servInstId); // delete from table
+        // collection_output
+    }
+
+    /**
+     * delete the service instance by service name and signature URL
+     * 
+     * @param servName
+     *            the name of service which we want delete.
+     * @param signURL
+     *            the authority URI for service which we want delete.
+     *  
+     */
+
+    public static void delServByNameAndUrl(String servName, String signURL) {
+
+        int authId = getAuthIdByServNameAndSignURL(servName, signURL);
+        int servInstId = getServInstId(servName, authId);
+
+        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
+        delRow("secondary_input", servInstId); //TODO - should this line be
+                                               // here?
+        delCollectionMember("input", servInstId);
+        delCollectionMember("output", servInstId);
+        delRow("collection_input", servInstId); // delete from table
+        // collection_input
+        delRow("collection_output", servInstId); // delete from table
+        // collection_output
+    }
+
+    /**
+     * delete set of the service instances with the same signatureURL by
+     * signatureURL
+     * 
+     * @param signURL
+     *            the name of service which we want delete.
+     */
+
+    public static void delServiceSetByURL(String signURL) {
+
+        Connection con = DBConnector.getConnection();
+
+        final String sqlReq1 = "select service_instance_id,servicename,authority_id from service_instance where signatureURL = ?";
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setString(1, signURL);
+            rs = ps.executeQuery();
+            Vector del_serv = new Vector();
+
+            while (rs.next()) {
+                int servInstId = rs.getInt(1);
+                String servName = rs.getString(2);
+                int authId = rs.getInt(3);
+
+                int rez = delSignature(servName, authId); // delete service from
+                // table
+                // service_instance
+                if (rez == 1) {
+                    del_serv.addElement(servName);
+                }
+                delRow("secondary_input", servInstId); //TODO - should this
+                                                       // line be here?
+                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
+            }
+
+            int del = del_serv.size();
+            if (del > 0) {
+                Report.doWrite("DELETED SERVICES: ");
+                Iterator i = del_serv.iterator();
+                int n = 1;
+                while (i.hasNext()) {
+                    String delServ = i.next().toString();
+                    Report.doWrite(n + ". " + delServ);
+                    n += 1;
+                }
+            }
+
+        } catch (SQLException e) {
+            Log.severe(e.getMessage());
+            //			e.getMessage();
+        } finally {
+            try {
+                if (rs != null)
+                    rs.close();
+            } catch (SQLException e) {
+            }
+            try {
+                if (ps != null)
+                    ps.close();
+            } catch (SQLException e) {
+                Log.severe(e.getMessage());
+            }
+        }
+
+    }
+
+    /**
+     * add the record about new service instance in the service_instance table
+     * of mobycentral database
+     * 
+     * @param servName -
+     *            the name of service instance the record was added for.
+     * @param cat -
+     *            the category of service instance.
+     * @param servTypeURI -
+     *            the service type URI of service instance.
+     * @param authId -
+     *            the authority Id of service instance.
+     * @param url -
+     *            the URL of service instance.
+     * @param email -
+     *            the contact e-Mail of service instance.
+     * @param authoritative -
+     *            the authoritative of service instance.
+     * @param desc -
+     *            the description of service instance.
+     * @param signURL -
+     *            the URL for RDF of service instance.
+     * @return ret=1 if the record has added, and ret=-1 otherwise
+     */
+
+    public static int createSignature(String servName, String cat,
+            String servTypeURI, int authId, String url, String email,
+            String authoritative, String desc, String signURL) {
+
+        Connection con = DBConnector.getConnection();
+
+        int ret = -1;
+
+        final String sqlReq1 = "insert into service_instance (servicename,category,service_type_uri,authority_id,url,contact_email,authoritative,description,signatureURL) values (?,?,?,?,?,?,?,?,?)";
+        PreparedStatement ps = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setString(1, servName);
+            ps.setString(2, cat);
+            ps.setString(3, servTypeURI);
+            ps.setInt(4, authId);
+            ps.setString(5, url);
+            ps.setString(6, email);
+            ps.setString(7, authoritative);
+            ps.setString(8, desc);
+            ps.setString(9, signURL);
+
+            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;
+    }
+
+    /**
+     * update the service instance data in the service_instance table of
+     * mobycentral database
+     * 
+     * @param servName
+     *            the name of service instance the record was updated for.
+     * @param cat
+     *            the category of service instance.
+     * @param stype
+     *            the service type URI of service instance.
+     * @param authuri
+     *            the authority URI of service instance.
+     * @param url
+     *            the URL of service instance.
+     * @param email
+     *            the contact e-Mail of service instance.
+     * @param authoritative
+     *            the authoritative of service instance.
+     * @param desc
+     *            the description of service instance.
+     * @param signURL
+     *            the URL for RDF of service instance.
+     * @return ret=1 if the record has updated, and ret=-1 otherwise
+     */
+
+    public static int updSign(String servName, String cat, String stype,
+            String authuri, String url, String email, String desc,
+            String authoritative, String signURL) {
+
+        Connection con = DBConnector.getConnection();
+        int cnt = -1;
+        int ret = -1;
+        final String sqlReq = "select authority_id from authority where authority_uri = ?";
+        PreparedStatement ps = null;
+
+        final String sqlReq1 = "update service_instance set category = ?,service_type_uri = ?,url = ?,contact_email = ?,description = ?,authoritative = ?,signatureURL = ? where servicename = ? && authority_id = ?";
+        try {
+            ps = con.prepareStatement(sqlReq);
+            ps.setString(1, authuri);
+            ResultSet rs = ps.executeQuery();
+            while (rs.next()) {
+                cnt = rs.getInt(1);
+            }
+            if (cnt > -1) {
+                ps = con.prepareStatement(sqlReq1);
+                ps.setString(1, cat);
+                ps.setString(2, stype);
+                ps.setString(3, url);
+                ps.setString(4, email);
+                ps.setString(5, desc);
+                ps.setString(6, authoritative);
+                ps.setString(7, signURL);
+                ps.setString(8, servName);
+                ps.setInt(9, cnt);
+                ret = ps.executeUpdate();
+            }
+
+        } catch (SQLException e) {
+            //					e.getMessage();
+            Log.severe(e.getMessage());
+        } finally {
+            try {
+                if (ps != null)
+                    ps.close();
+            } catch (SQLException e) {
+                Log.severe(e.getMessage());
+                //							e.getMessage();
+            }
+        }
+        return ret;
+    }
+
+    /**
+     * add the record into the simple_input table
+     * 
+     * @param servInstId
+     *            the Id of service instance the simple input was added for.
+     * @param articleName
+     *            the article name of the simple input.
+     * @param objTypeUri
+     *            the object type URI of the simple input.
+     * @param nsTypeUris
+     *            the string with set of the nameSpaces for this simple input.
+     * @param colInpId
+     *            the collection input Id if this simple input belongs to a
+     *            collection, and blank otherwise.
+     */
+
+    public static void insIntoSimpleInput(Integer servInstId,
+            String articleName, String objTypeUri, String nsTypeUris,
+            Integer colInpId) {
+
+        Connection con = DBConnector.getConnection();
+
+        int ret = -1;
+
+        final String sqlReq1 = "insert into simple_input (service_instance_id,article_name,object_type_uri,namespace_type_uris,collection_input_id) values (?,?,?,?,?)";
+
+        PreparedStatement ps = null;
+        try {
+            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);
+            if (colInpId != null) {
+                ps.setInt(5, colInpId.intValue());
+            } else {
+                ps.setNull(5, java.sql.Types.INTEGER);
+            }
+
+            ret = ps.executeUpdate();
+
+        } catch (SQLException e) {
+            //					   e.getMessage();
+            Log.severe(e.getMessage());
+        } finally {
+            try {
+                if (ps != null)
+                    ps.close();
+            } catch (SQLException e) {
+                Log.severe(e.getMessage());
+                //							e.getMessage();
+            }
+        }
+    }
+
+    /**
+     * update the record into the simple_input table
+     * 
+     * @param servInstId
+     *            the Id of service instance the simple input was added for.
+     * @param articleName
+     *            the article name of the simple input.
+     * @param objTypeUri
+     *            the object type URI of the simple input.
+     * @param nsTypeUris
+     *            the string with set of the nameSpaces for this simple input.
+     * @param colInpId
+     *            the collection input Id if this simple input belongs to a
+     *            collection, and blank otherwise.
+     * @return ret=1 if the record has added, and ret=-1 otherwise
+     */
+
+    public static int updateSimpleInput(int servInstId, String articleName,
+            String objTypeUri, String nsTypeUris, Integer colInpId, int minNum) {
+
+        Connection con = DBConnector.getConnection();
+
+        int ret = -1;
+
+        final String sqlReq1 = "update simple_input set service_instance_id=?,article_name=?,object_type_uri=?,namespace_type_uris=?,collection_input_id=? where simple_input_id=?";
+
+        PreparedStatement ps = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setInt(1, servInstId);
+            ps.setString(2, articleName);
+            ps.setString(3, objTypeUri);
+            ps.setString(4, nsTypeUris);
+            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) {
+            Log.severe(e.getMessage());
+            //				        	e.getMessage();
+        } finally {
+            try {
+                if (ps != null)
+                    ps.close();
+            } catch (SQLException e) {
+                Log.severe(e.getMessage());
+                //							e.getMessage();
+            }
+        }
+        return ret;
+    }
+
+    /**
+     * add the record about secondary input in the secondary_input table of
+     * mobycentral database
+     * 
+     * @param servInstId
+     *            the Id of service instance the secondary input was added for.
+     * @param article_name
+     *            the article name of the secondary input.
+     * @param def
+     *            the default value of the secondary input.
+     * @param dataType
+     *            the type of data of the secondary input.
+     * @param max
+     *            the maximum value of the secondary input
+     * @param min
+     *            the minimum value of the secondary input *
+     * @param enumeration
+     *            the enumeration value for the secondary input
+     */
+
+    public static void insIntoSecondary(int servInstId, String article_name,
+            String def, String dataType, BigDecimal max, BigDecimal min,
+            String enumeration) {
+
+        Connection con = DBConnector.getConnection();
+
+        int ret = -1;
+
+        final String sqlReq1 = "insert into secondary_input (service_instance_id,article_name,default_value,maximum_value,minimum_value,enum_value,datatype) values (?,?,?,?,?,?,?)";
+
+        PreparedStatement ps = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setInt(1, servInstId);
+            ps.setString(2, article_name);
+            ps.setString(3, def);
+            ps.setBigDecimal(4, max);
+            ps.setBigDecimal(5, min);
+            ps.setString(6, enumeration);
+            ps.setString(7, dataType);
+
+            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();
+            }
+        }
+    }
+
+    /**
+     * update the record into the secondary_input table
+     * 
+     * @param servInstId
+     *            the Id of service instance the secondary input was added for.
+     * @param article_name
+     *            the article name of the secondary input.
+     * @param def
+     *            the default value of the secondary input.
+     * @param dataType
+     *            the type of data of the secondary input.
+     * @param max
+     *            the maximum value of the secondary input
+     * @param min
+     *            the minimum value of the secondary input
+     * @param enumeration
+     *            the enumeration value for the secondary input
+     * @param minSecNum
+     *            minimum free number for secondary_input_id
+     */
+
+    public static void updateSec(int servInstId, String article_name,
+            String def, String dataType, BigDecimal max, BigDecimal min,
+            String enumeration, int minSecNum) {
+
+        Connection con = DBConnector.getConnection();
+
+        int ret = -1;
+
+        final String sqlReq1 = "update secondary_input set service_instance_id=?,article_name=?,default_value=?,maximum_value=?,minimum_value=?,enum_value=?,datatype=? where secondary_input_id=?";
+
+        PreparedStatement ps = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setInt(1, servInstId);
+            ps.setString(2, article_name);
+            ps.setString(3, def);
+            ps.setBigDecimal(4, max);
+            ps.setBigDecimal(5, min);
+            ps.setString(6, enumeration);
+            ps.setString(7, dataType);
+            ps.setInt(8, minSecNum);
+            ret = ps.executeUpdate();
+
+        } catch (SQLException e) {
+            //								e.getMessage();
+            Log.severe(e.getMessage());
+        } finally {
+            try {
+                if (ps != null)
+                    ps.close();
+            } catch (SQLException e) {
+                //									e.getMessage();
+                Log.severe(e.getMessage());
+            }
+        }
+    }
+
+    /**
+     * add the record into the simple_output table
+     * 
+     * @param servInstId
+     *            the Id of service instance the simple output was added for.
+     * @param articleName
+     *            the article name of the simple output.
+     * @param objTypeUri
+     *            the object type URI of the simple output.
+     * @param nsTypeUris
+     *            the string with set of the nameSpaces for this simple output.
+     * @param colOutId
+     *            the collection input Id if this simple output belongs to a
+     *            collection, and blank otherwise.
+     */
+
+    public static void insIntoSimpleOutput(Integer servInstId,
+            String articleName, String objTypeUri, String nsTypeUris,
+            Integer colOutId) {
+
+        Connection con = DBConnector.getConnection();
+
+        int ret = -1;
+
+        final String sqlReq1 = "insert into simple_output (service_instance_id,article_name,object_type_uri,namespace_type_uris,collection_output_id) values (?,?,?,?,?)";
+
+        PreparedStatement ps = null;
+
+        try {
+            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);
+            if (colOutId != null) {
+                ps.setInt(5, colOutId.intValue());
+            } else {
+                ps.setNull(5, java.sql.Types.INTEGER);
+            }
+
+            ret = ps.executeUpdate();
+
+        } catch (SQLException e) {
+            //								e.getMessage();
+            Log.severe(e.getMessage());
+        } finally {
+            try {
+                if (ps != null)
+                    ps.close();
+            } catch (SQLException e) {
+                Log.severe(e.getMessage());
+                //									e.getMessage();
+            }
+
+        }
+
+    }
+
+    /**
+     * update the record into the simple_output table
+     * 
+     * @param servInstId
+     *            the Id of service instance the simple output was added for.
+     * @param articleName
+     *            the article name of the simple output.
+     * @param objTypeUri
+     *            the object type URI of the simple output.
+     * @param nsTypeUris
+     *            the string with set of the nameSpaces for this simple output.
+     * @param colOutId
+     *            the collection input Id if this simple output belongs to a
+     *            collection, and blank otherwise.
+     * @return ret=1 if the record has added, and ret=-1 otherwise
+     */
+
+    public static int updateSimpleOutput(int servInstId, String articleName,
+            String objTypeUri, String nsTypeUris, int colOutId, int minNum) {
+
+        Connection con = DBConnector.getConnection();
+
+        int ret = -1;
+
+        final String sqlReq1 = "update simple_output set service_instance_id=?,article_name=?,object_type_uri=?,namespace_type_uris=?,collection_output_id=? where simple_output_id=?";
+
+        PreparedStatement ps = null;
+
+        try {
+            ps = con.prepareStatement(sqlReq1);
+
+            ps.setInt(1, servInstId);
+            ps.setString(2, articleName);
+            ps.setString(3, objTypeUri);
+            ps.setString(4, nsTypeUris);
+            ps.setInt(5, colOutId);
+            ps.setInt(6, minNum);
+            ret = ps.executeUpdate();
+
+        } catch (SQLException e) {
+            //								e.getMessage();
+            Log.severe(e.getMessage());
+        } finally {
+            try {
+                if (ps != null)
+                    ps.close();
+            } catch (SQLException e) {
+                Log.severe(e.getMessage());
+                //									e.getMessage();
+            }
+
+        }
+
+        return ret;
+    }
+
+    /**
+     * get the number of errors for the given return code and URL of resource
+     * 
+     * @param signURL -
+     *            the URL of resource was gotten the return code for.
+     * @param errCode -
+     *            the error code, connection was refused
+     * @return Intrger number of error if was found in the database, zero
+     *         otherwise
+     */
+
+    public static int getServErrorNum(String signURL, int errCode) {
+
+        int num = 0;
+
+        Connection con = DBConnector.getConnection();
+
+        final String sqlReq1 = "select counter from service_validation where signatureURL = ? and error_code = ?";
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setString(1, signURL);
+            ps.setInt(2, errCode);
+            rs = ps.executeQuery();
+
+            while (rs.next()) {
+                int cnt = rs.getInt(1);
+                num = cnt;
+
+            }
+
+        } catch (SQLException e) {
+            //			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();
+            }
+
+        }
+
+        return num;
+
+    }
+
+    /**
+     * get the service signature data for service instance by the service name
+     * and signatureURL
+     * 
+     * @param signURL -
+     *            the URL of service RDF
+     * @param servName -
+     *            the name of service
+     * @return carrier class ServSignature
+     */
+
+    public static ServSignature getServSignature(String servName, String signURL) {
+
+        ServSignature signature = new ServSignature();
+
+        Connection con = DBConnector.getConnection();
+
+        final String sqlReq1 = "select service_instance_id,authority_id,category,service_type_uri,url,contact_email,authoritative,description from service_instance where servicename=? and signatureURL = ?";
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setString(1, servName);
+            ps.setString(2, signURL);
+            rs = ps.executeQuery();
+
+            while (rs.next()) {
+                int servInstId = rs.getInt(1);
+                signature.setServInstId(servInstId);
+                int authId = rs.getInt(2);
+                signature.setAuthId(authId);
+                String category = rs.getString(3);
+                signature.setCategory(category);
+                String serviceType = rs.getString(4);
+                signature.setServiceType(serviceType);
+                String url = rs.getString(5);
+                signature.setUrl(url);
+                String email = rs.getString(6);
+                signature.setEmail(email);
+                String authoritative = rs.getString(7);
+                signature.setAuthoritative(authoritative);
+                String description = rs.getString(8);
+                signature.setDescription(description);
+                signature.setServiceName(servName);
+                signature.setSignatureURL(signURL);
+            }
+
+        } catch (SQLException e) {
+            //				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();
+            }
+
+        }
+
+        return signature;
+
+    }
+
+    /**
+     * get the secondary input data by the secondary input Id
+     * 
+     * @param servInstId -
+     *            the secondary input Id
+     * @return carrier class Secondary
+     */
+
+    public static Secondary getSecondary(int servInstId) {
+
+        Secondary second = new Secondary();
+
+        Connection con = DBConnector.getConnection();
+
+        final String sqlReq1 = "select default_value,maximum_value,minimum_value,enum_value,datatype,article_name from secondary_input where service_instance_id = ?";
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setInt(1, servInstId);
+            rs = ps.executeQuery();
+            int open_sec = 0;
+            while (rs.next()) {
+                String defaultValue = rs.getString(1);
+                second.setDefaultValue(defaultValue);
+                BigDecimal maximumValue = rs.getBigDecimal(2);
+                second.setMaximumValue(maximumValue);
+                BigDecimal minimumValue = rs.getBigDecimal(3);
+                second.setMinimumValue(minimumValue);
+                String enumValue = rs.getString(4);
+                second.setEnumValue(enumValue);
+                String datatype = rs.getString(5);
+                second.setDatatype(datatype);
+                String articleName = rs.getString(6);
+                second.setArticleName(articleName);
+
+                XMLBuilder.buildSecondXml(second);
+            }
+
+        } catch (SQLException e) {
+            //					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();
+            }
+
+        }
+
+        return second;
+
+    }
+
+    /**
+     * get the simple/collection output data by the service instance Id and
+     * build xml representation
+     * 
+     * @param servInstId -
+     *            the service instance Id
+     */
+
+    public static void getSimpleCollectOutput(int servInstId) {
+
+        Connection con = DBConnector.getConnection();
+
+        final String sqlReq1 = "select article_name,namespace_type_uris,object_type_uri,collection_output_id from simple_output where service_instance_id = ?";
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setInt(1, servInstId);
+            rs = ps.executeQuery();
+
+            while (rs.next()) {
+                String artName = rs.getString(1);
+                String nsType = rs.getString(2);
+                String objType = rs.getString(3);
+                //			   int colOutId = rs.getInt(4);
+                String type;
+                Integer colOutId = new Integer(rs.getInt(4));
+                if (colOutId == null) {
+                    type = "so";
+                } else {
+                    type = "co";
+                }
+
+                XMLBuilder.buildInpOutXml(artName, nsType, objType, type);
+            }
+        } catch (SQLException e) {
+            //		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();
+            }
+        }
+    }
+
+    /**
+     * get the simple/collection input data by the service instance Id and build
+     * xml representation
+     * 
+     * @param servInstId -
+     *            the service instance Id
+     */
+
+    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;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setInt(1, servInstId);
+            rs = ps.executeQuery();
+
+            while (rs.next()) {
+                String artName = rs.getString(1);
+                String nsType = rs.getString(2);
+                String objType = rs.getString(3);
+                String type;
+                //				   int colInpId = rs.getInt(4);
+                Integer colInpId = new Integer(rs.getInt(4));
+                if (colInpId == null) {
+                    type = "si";
+                } else {
+                    type = "ci";
+                }
+
+                XMLBuilder.buildInpOutXml(artName, nsType, objType, type);
+            }
+
+        } catch (SQLException e) {
+            //			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();
+            }
+
+        }
+    }
+
+    /**
+     * update the counter for the given return code and URL of resource
+     * 
+     * @param signURL -
+     *            the URL of resource was updated the counter for.
+     * @param errCode -
+     *            the error code was encreased the counter for.
+     * @return Intrger ret=1 if the record was updated, ret=-1 otherwise
+     */
+
+    public static int updErrCount(String signURL, int errCode) {
+
+        Connection con = DBConnector.getConnection();
+
+        int ret = -1;
+
+        final String sqlReq1 = "update service_validation set error_code = ?,counter=counter+1 where signatureURL = ?";
+        PreparedStatement ps = null;
+
+        try {
+            ps = con.prepareStatement(sqlReq1);
+
+            ps.setInt(1, errCode);
+            ps.setString(2, signURL);
+            ret = ps.executeUpdate();
+
+        } catch (SQLException e) {
+
+            Log.severe(e.getMessage());
+        } finally {
+            try {
+                if (ps != null)
+                    ps.close();
+            } catch (SQLException e) {
+                Log.severe(e.getMessage());
+                //							e.getMessage();
+            }
+
+        }
+
+        return ret;
+    }
+
+    /**
+     * add new record to the service_validation table of the mobycentral
+     * database
+     * 
+     * @param signURL -
+     *            the URL of resource the connection was refused for.
+     * @param errCode -
+     *            the error code, connection was refused
+     * @return Intrger ret=1 if the record was added, ret=-1 otherwise
+     */
+
+    public static int insErrCount(String signURL, int errCode) {
+
+        Connection con = DBConnector.getConnection();
+
+        int ret = -1;
+
+        final String sqlReq1 = "insert into service_validation (signatureURL,error_code,counter) values (?,?,1)";
+        PreparedStatement ps = null;
+
+        try {
+            ps = con.prepareStatement(sqlReq1);
+
+            ps.setString(1, signURL);
+            ps.setInt(2, errCode);
+            ret = ps.executeUpdate();
+
+        } catch (SQLException e) {
+            //							e.getMessage();
+            Log.severe(e.getMessage());
+        } finally {
+            try {
+                if (ps != null)
+                    ps.close();
+            } catch (SQLException e) {
+                Log.severe(e.getMessage());
+                //								e.getMessage();
+            }
+
+        }
+
+        return ret;
+    }
+
+    /**
+     * delete the record from service_validation table by signatureURL
+     * 
+     * @param signURL -
+     *            the URL of resource the record was deleted for.
+     * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise.
+     */
+
+    public static int delServErrors(String signURL) {
+
+        Connection con = DBConnector.getConnection();
+        int ret = -1;
+        final String sqlReq1 = "delete from service_validation where signatureURL = ?";
+        PreparedStatement ps = null;
+
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setString(1, signURL);
+            ret = ps.executeUpdate();
+
+        } 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;
+
+    }
+
+    /**
+     * get the service instance Id for the given service name and authority Id
+     * 
+     * @param servName -
+     *            the name of service instance .
+     * @param authId -
+     *            the authority Id for the service instance.
+     * @return Intrger service instance Id if was found in the database, zero
+     *         otherwise
+     */
+
+    public static int getServInstId(String servName, int authId) {
+
+        int servInsId = 0;
+
+        Connection con = DBConnector.getConnection();
+
+        final String sqlReq1 = "select service_instance_id from service_instance where servicename = ? && authority_id = ?";
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setString(1, servName);
+            ps.setInt(2, authId);
+            rs = ps.executeQuery();
+
+            while (rs.next()) {
+                servInsId = rs.getInt(1);
+
+            }
+
+        } catch (SQLException e) {
+            Log.severe(e.getMessage());
+            //						e.getMessage();
+        } finally {
+            try {
+                if (rs != null)
+                    rs.close();
+            } catch (SQLException e) {
+            }
+            try {
+                if (ps != null)
+                    ps.close();
+            } catch (SQLException e) {
+                Log.severe(e.getMessage());
+                //									e.getMessage();
+            }
+
+        }
+
+        return servInsId;
+    }
+
+    /**
+     * get the service instance Id for the given service name and signatureURL
+     * 
+     * @param servName -
+     *            the name of service instance .
+     * @param signURL -
+     *            URL of resource for the service instance.
+     * @return Intrger service instance Id if was found in the database, zero
+     *         otherwise
+     */
+
+    public static int getServInstId(String servName, String signURL) {
+
+        int servInsId = 0;
+
+        Connection con = DBConnector.getConnection();
+
+        final String sqlReq1 = "select service_instance_id from service_instance where servicename = ? && signatureURL = ?";
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setString(1, servName);
+            ps.setString(2, signURL);
+            rs = ps.executeQuery();
+
+            while (rs.next()) {
+                servInsId = rs.getInt(1);
+
+            }
+
+        } catch (SQLException e) {
+            Log.severe(e.getMessage());
+            //							e.getMessage();
+        } finally {
+            try {
+                if (rs != null)
+                    rs.close();
+            } catch (SQLException e) {
+            }
+            try {
+                if (ps != null)
+                    ps.close();
+            } catch (SQLException e) {
+                Log.severe(e.getMessage());
+                //										e.getMessage();
+            }
+
+        }
+
+        return servInsId;
+    }
+
+    /**
+     * get the set of services for the given URL of resource by signatureURL
+     * 
+     * @param signURL -
+     *            the URL of resource .
+     * @return String set of the services which was found in the database, empty
+     *         string otherwise
+     */
+
+    public static String getServListByURL(String signURL) {
+
+        StringBuffer servList = new StringBuffer();
+
+        Connection con = DBConnector.getConnection();
+
+        final String sqlReq1 = "select servicename from service_instance where signatureURL = ?";
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setString(1, signURL);
+            rs = ps.executeQuery();
+
+            while (rs.next()) {
+                String servName = rs.getString(1);
+                servList.append(servName + ",");
+            }
+
+        } catch (SQLException e) {
+            Log.severe(e.getMessage());
+            //							e.getMessage();
+        } finally {
+            try {
+                if (rs != null)
+                    rs.close();
+            } catch (SQLException e) {
+            }
+            try {
+                if (ps != null)
+                    ps.close();
+            } catch (SQLException e) {
+                Log.severe(e.getMessage());
+                //										e.getMessage();
+            }
+
+        }
+
+        return servList.toString();
+    }
+
+    /**
+     * delete a record from given table by a service instance Id (the metod is
+     * working for simple_input/output, collection input/output tables)
+     * 
+     * @param servInstId -
+     *            the service instance Id.
+     * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise.
+     */
+
+    public static int delRow(String tableName, int servInstId) {
+
+        Connection con = DBConnector.getConnection();
+
+        int ret = -1;
+
+        final String sqlReq1 = "delete from " + tableName
+                + " where service_instance_id = ?";
+
+        PreparedStatement ps = null;
+
+        try {
+            ps = con.prepareStatement(sqlReq1);
+
+            ps.setInt(1, servInstId);
+
+            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;
+    }
+
+    /**
+     * delete a record from simple table by a service instance Id and
+     * collection_input_id (the metod is working for simple_input/output,
+     * collection input/output tables)
+     * 
+     * @param servInstId -
+     *            the service instance Id.
+     */
+
+    public static void delCollectionMember(String inout, int servInstId) {
+
+        Connection con = DBConnector.getConnection();
+
+        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 {
+                    ps1 = con.prepareStatement(sqlReq);
+                    //							    ps.setInt(1, servInstId);
+                    ps1.executeUpdate();
+                } catch (SQLException e) {
+                    Log.severe(e.getMessage());
+                } finally {
+                    try {
+                        if (ps1 != null)
+                            ps1.close();
+                    } catch (SQLException e) {
+                        Log.severe(e.getMessage());
+                    }
+                }
+            }
+
+        } 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
+     * 
+     * @param servName -
+     *            the service instance name.
+     * @param authId -
+     *            the id of the authority
+     * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise.
+     */
+
+    public static int delSignature(String servName, int authId) {
+
+        Connection con = DBConnector.getConnection();
+
+        int ret = -1;
+
+        //			if (authId == 0){
+        final String sqlReq1 = "delete from service_instance where servicename= ? and authority_id = ?";
+        PreparedStatement ps = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setString(1, servName);
+            ps.setInt(2, authId);
+            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;
+    }
+
+    /**
+     * get the collection Id from collection_input or collection_output table by
+     * the service_instance_id
+     * 
+     * @param table -
+     *            the collection_input or collection_output table
+     * @param field -
+     *            "collection_input_id" (for collection_input table) and
+     *            "collection_output_id" (for collection_output table)
+     * @param servInstId -
+     *            Id of service instance
+     * @return Integer collection Id if was found, zero otherwise.
+     */
+
+    public static int getCollectionId(String table, String field, int servInstId) {
+
+        int colId = 0;
+
+        Connection con = DBConnector.getConnection();
+
+        final String sqlReq1 = "select "
+                + field
+                + " from "
+                + table
+                + " where service_instance_id = ? order by service_instance_id,"
+                + field + " ASC";
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setInt(1, servInstId);
+            rs = ps.executeQuery();
+
+            while (rs.next()) {
+                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();
+            }
+
+        }
+
+        return colId;
+
+    }
+
+    /**
+     * add new record into the collection_input or collection_output table
+     * 
+     * @param table -
+     *            the collection_input or collection_output table
+     * @param artName -
+     *            the artical name of the collection_input or collection_output
+     * @param servInstId -
+     *            Id of service instance
+     * @return Intrger ret=1 if the record was added, ret=-1 otherwise
+     */
+
+    public static int insIntoCol(String table, String artName, int servInstId) {
+
+        Connection con = DBConnector.getConnection();
+
+        int ret = -1;
+
+        final String sqlReq1 = "insert into " + table
+                + " (article_name,service_instance_id) values (?,?)";
+        PreparedStatement ps = null;
+
+        try {
+            ps = con.prepareStatement(sqlReq1);
+
+            ps.setString(1, artName);
+            ps.setInt(2, servInstId);
+            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;
+    }
+
+    /**
+     * update record into the collection_input or collection_output table
+     * 
+     * @param table -
+     *            the collection_input or collection_output table
+     * @param key_field -
+     *            collection_input_id for collection_input table,
+     *            collection_output_id for collection_output table;
+     * @param artName -
+     *            the artical name of the collection_input or collection_output
+     * @param servInstId -
+     *            Id of service instance
+     * @return Intrger ret=1 if the record was added, ret=-1 otherwise
+     */
+
+    public static int updateCol(String table, String key_field, String artName,
+            int servInstId, int minNum) {
+
+        Connection con = DBConnector.getConnection();
+
+        int ret = -1;
+
+        final String sqlReq1 = "update " + table
+                + " set article_name=?,service_instance_id=? where "
+                + key_field + " =?";
+
+        PreparedStatement ps = null;
+
+        try {
+            ps = con.prepareStatement(sqlReq1);
+
+            ps.setString(1, artName);
+            ps.setInt(2, servInstId);
+            ps.setInt(3, minNum);
+            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;
+    }
+
+    /**
+     * get the service authority URI from authority table by the servicename
+     * 
+     * @param servName -
+     *            the name of service
+     * @return String authority URI if was found, empty string otherwise.
+     */
+
+    public static String getServAuthURI(String servName) {
+
+        Connection con = DBConnector.getConnection();
+
+        String authURI = "";
+
+        final String sqlReq1 = "select authority_uri from service_instance si,authority a where si.authority_id=a.authority_id and si.servicename=?";
+        ;
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setString(1, servName);
+            rs = ps.executeQuery();
+
+            while (rs.next()) {
+                authURI = rs.getString(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();
+            }
+
+        }
+
+        return authURI;
+
+    }
+
+    /**
+     * get the service authority Id from service_instance table by the
+     * servicename and signatureURL
+     * 
+     * @param serviceName -
+     *            the name of service
+     * @param signURL -
+     *            the signatureURL for the given service
+     * @return int authority Id if was found, zero otherwise.
+     */
+
+    public static int getAuthIdByServNameAndSignURL(String serviceName,
+            String signURL) {
+
+        int authId = 0;
+
+        Connection con = DBConnector.getConnection();
+
+        final String sqlReq1 = "select authority_id from service_instance where servicename = ? and signatureURL = ?";
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setString(1, serviceName);
+            ps.setString(2, signURL);
+            rs = ps.executeQuery();
+
+            while (rs.next()) {
+                authId = rs.getInt(1);
+
+            }
+
+        } catch (SQLException e) {
+            Log.severe(e.getMessage());
+            //					  e.getMessage();
+        } finally {
+            try {
+                if (rs != null)
+                    rs.close();
+            } catch (SQLException e) {
+            }
+            try {
+                if (ps != null)
+                    ps.close();
+            } catch (SQLException e) {
+                Log.severe(e.getMessage());
+                //							    	e.getMessage();
+            }
+
+        }
+
+        return authId;
+    }
+
+    /**
+     * add new record to the authority table
+     * 
+     * @param authURI -
+     *            the authority URI
+     * @param email -
+     *            the contact e-Mail
+     * @return Intrger ret=1 if the record was added, ret=-1 otherwise
+     */
+
+    public static int insIntoAuthority(String authURI, String email) {
+
+        Connection con = DBConnector.getConnection();
+
+        int ret = -1;
+
+        final String sqlReq1 = "insert into authority (authority_common_name,authority_uri,contact_email) values (null,?,?)";
+        PreparedStatement ps = null;
+
+        try {
+            ps = con.prepareStatement(sqlReq1);
+
+            ps.setString(1, authURI);
+            ps.setString(2, email);
+            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;
+    }
+
+    /**
+     * get the service authority Id from authority table by the authority URI
+     * 
+     * @param authURI -
+     *            the authority URI
+     * @return int authority Id if was found, zero otherwise.
+     */
+
+    public static int getAuthIdByAuthURI(String authURI) {
+
+        int authId = 0;
+
+        Connection con = DBConnector.getConnection();
+
+        final String sqlReq1 = "select authority_id from authority where authority_uri = ?";
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setString(1, authURI);
+
+            rs = ps.executeQuery();
+
+            while (rs.next()) {
+                authId = rs.getInt(1);
+            }
+
+        } catch (SQLException e) {
+            //				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();
+            }
+
+        }
+
+        return authId;
+
+    }
+
+    /**
+     * get the contact e-Mail from service_instance table by the servicename
+     * 
+     * @param signURL -
+     *            the URL of a resource
+     * @return String contact e-Mail if was found, empty string otherwise.
+     */
+
+    public static String getContactEmail(String signURL) {
+
+        String email = "";
+
+        Connection con = DBConnector.getConnection();
+
+        final String sqlReq1 = "select contact_email from service_instance where signatureURL = ? ";
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            ps.setString(1, signURL);
+            rs = ps.executeQuery();
+
+            while (rs.next()) {
+                String cnt = rs.getString(1);
+                email = cnt;
+
+            }
+
+        } catch (SQLException e) {
+
+            //					   e.printStackTrace();
+            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();
+            }
+
+        }
+        //System.out.println("email = "+email);
+        return email;
+
+    }
+
+    /**
+     * 
+     * gets the min number of records with service instance id = 0
+     * 
+     * @param table
+     * @param key_field
+     * @return the number of records
+     */
+
+    public static int getMinFreeNumber(String table, String key_field) {
+
+        int num = 0;
+
+        Connection con = DBConnector.getConnection();
+
+        final String sqlReq1 = "select min(" + key_field + ") from " + table
+                + " where service_instance_id = 0 order by " + key_field;
+
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        try {
+            ps = con.prepareStatement(sqlReq1);
+            rs = ps.executeQuery();
+
+            while (rs.next()) {
+                num = rs.getInt(1);
+            }
+
+        } catch (SQLException e) {
+
+            //						   e.printStackTrace();
+            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();
+            }
 
-		}
+        }
 
-		return num;
+        return num;
 
-	}
+    }
 
 }
 




More information about the MOBY-guts mailing list