[MOBY-guts] biomoby commit
Eddie Kawas
kawas at dev.open-bio.org
Wed Oct 11 01:54:50 UTC 2006
kawas
Tue Oct 10 21:54:50 EDT 2006
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms
In directory dev.open-bio.org:/tmp/cvs-serv25229/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms
Modified Files:
Lsid_resolver.java CallableServicesServlet.java
GetSignatureRDFResponse.java GetSignatureRDFForm.java
RDFAgentValidator.java LSID_ResolverClient.java
LSIDComplete.java
Added Files:
GetServiceRDF.java
Log Message:
moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms GetServiceRDF.java,NONE,1.1 Lsid_resolver.java,1.3,1.4 CallableServicesServlet.java,1.2,1.3 GetSignatureRDFResponse.java,1.8,1.9 GetSignatureRDFForm.java,1.4,1.5 RDFAgentValidator.java,1.2,1.3 LSID_ResolverClient.java,1.1,1.2 LSIDComplete.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/Lsid_resolver.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/Lsid_resolver.java 2006/05/24 18:48:31 1.3
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/Lsid_resolver.java 2006/10/11 01:54:50 1.4
@@ -93,21 +93,21 @@
String str = resolveLSID(lsid_to_use, "soap");
return str;
} catch (MobyException e) {
- e.printStackTrace();
+ log.debug("Couldn't resolve " + lsid_to_use + " to metadata using SOAP.");
}
try {
String str = resolveLSID(lsid_to_use, "http");
return str;
} catch (MobyException e) {
- e.printStackTrace();
+ log.debug("Couldn't resolve " + lsid_to_use + " to metadata using HTTP.");
}
try {
String str = resolveLSID(lsid_to_use, "ftp");
return str;
} catch (MobyException e) {
- e.printStackTrace();
+ log.debug("Couldn't resolve " + lsid_to_use + " to metadata using FTP.");
}
- return "Couldn't resolve your lsid. I tried the protocols SOAP, HTTP, and FTP. If we are missing one, let us know.";
+ return "Couldn't resolve your lsid to metadata (perhaps there is none?). I tried the protocols SOAP, HTTP, and FTP. If we are missing one, let us know.";
}
/**
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/CallableServicesServlet.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/CallableServicesServlet.java 2006/08/30 23:15:17 1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/CallableServicesServlet.java 2006/10/11 01:54:50 1.3
@@ -18,16 +18,18 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.discovery.tools.DiscoverSingleton;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.biomoby.client.CentralImpl;
+import org.biomoby.client.ui.graphical.servlet.utilities.ContextLoader;
import org.biomoby.client.ui.graphical.servlet.utilities.ServiceTester;
import org.biomoby.shared.MobyException;
import org.biomoby.shared.MobyService;
/**
- * @author Eddie Kawas
- * This class was created to call out to all registered services and see which ones are alive.
+ * @author Eddie Kawas This class was created to call out to all registered
+ * services and see which ones are alive.
*/
public class CallableServicesServlet extends HttpServlet {
@@ -45,13 +47,27 @@
public void init(ServletConfig arg0) throws ServletException {
super.init(arg0);
+
+ ContextLoader cLoader = null;
+ try {
+ cLoader = (ContextLoader) DiscoverSingleton.find(Class
+ .forName((String) ContextLoader.class.getCanonicalName()), Class.forName(
+ (String) ContextLoader.class.getCanonicalName()).getName());
+ log
+ .warn((cLoader == null ? "ContextLoader is null and is therefore not loaded. This is BAD!"
+ : "ContextLoader has loaded successfully."));
+ } catch (Exception e) {
+ log.warn("ContextLoader is null and is therefore not loaded. This is BAD!"
+ + System.getProperty("line.separator") + e.getStackTrace());
+ }
+
log.info("initializing CallableServiceServlet");
scheduler = new ServiceTesterRunner();
Timer timer = new Timer();
Calendar calendar = Calendar.getInstance();
Date time = calendar.getTime();
log.info("Scheduling on going task.");
- timer.scheduleAtFixedRate(scheduler, time, 1000 * 60 * 60 );
+ timer.scheduleAtFixedRate(scheduler, time, 1000 * 60 * 60);
}
/*
@@ -156,7 +172,11 @@
public ServiceTesterRunner() {
try {
// TODO make this generic so that others can use it
- t = new ServiceTester(CentralImpl.DEFAULT_ENDPOINT, CentralImpl.DEFAULT_NAMESPACE);
+ t = new ServiceTester(
+ System.getProperty("MOBY_SERVER") == null ? CentralImpl.DEFAULT_ENDPOINT
+ : System.getProperty("MOBY_SERVER"),
+ System.getProperty("MOBY_URI") == null ? CentralImpl.DEFAULT_NAMESPACE
+ : System.getProperty("MOBY_URI"));
} catch (MobyException e) {
log.error("Couldn't instantiate a ServiceTester object", e);
}
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFResponse.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFResponse.java 2006/08/30 16:55:02 1.8
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFResponse.java 2006/10/11 01:54:50 1.9
@@ -1,20 +1,27 @@
package org.biomoby.client.ui.graphical.servlet.forms;
-import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Properties;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.sql.DataSource;
+import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.biomoby.client.rdf.builder.ServiceInstanceRDF;
+import org.biomoby.registry.properties.MobyProperties;
+
+import java.sql.Connection;
/*
* Created on Jan 14, 2005 <p>
@@ -38,7 +45,9 @@
final private String newline = System.getProperty("line.separator");
- final static private String error = "<html>" + System.getProperty("line.separator") + ""
+ private String SERVER_NAME = "";
+ final static private String getErrorString() {
+ return "<html>" + System.getProperty("line.separator") + ""
+ "<head>" + System.getProperty("line.separator") + ""
+ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">" + System.getProperty("line.separator") + ""
+ "<title>Please Try Again</title>" + System.getProperty("line.separator") + ""
@@ -48,11 +57,13 @@
+ "<h1>Unable to update your information</h1>" + System.getProperty("line.separator") + ""
+ "<blockquote>" + System.getProperty("line.separator") + ""
+ " <h3>Make sure that you specify a valid signature url! This field looks like the following: http://myAuthority.domain/path/to/rdf/for/service. Also make sure that you have specified the right case-sensitive service name, if applicable.</h3>" + System.getProperty("line.separator") + ""
- + " <p><a href=\"http://mobycentral.icapture.ubc.ca/servlets/forms/getSignatureForm\" target=\"_self\"><strong>Back</strong></a></p>" + System.getProperty("line.separator") + ""
+ + " <p><a href=\"javascript:history.back()\" target=\"_self\"><strong>Back</strong></a></p>" + System.getProperty("line.separator") + ""
+ "</blockquote>" + System.getProperty("line.separator") + "" + "</body>" + System.getProperty("line.separator") + "" + "</html>";
+ }
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
+ SERVER_NAME = request.getServerName();
String domain = filter(request.getParameter("domain"));
String serviceName = filter(request.getParameter("serviceName"));
String sigURL = filter(request.getParameter("sigURL"));
@@ -71,7 +82,7 @@
if (sigURL.equals("") || !isValidSig(sigURL)) {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
- out.println(error);
+ out.println(getErrorString());
return;
}
@@ -81,7 +92,7 @@
// update failed
response.setContentType("text/html");
PrintWriter out = response.getWriter();
- out.println(error);
+ out.println(getErrorString());
return;
}
/*get the rdf*/
@@ -104,31 +115,112 @@
return;
}
- /*
- * TODO you need place the updateSignatureURL in the cgi-bin directory
- */
private boolean updateMobyCentralDatabase(String domain, String sigURL,
String name) throws MalformedURLException {
String con;
if (name.equals("")) {
- log.info("empty name");
- con = "http://mobycentral.icapture.ubc.ca/cgi-bin/updateSignatureURL.cgi?authURI="
- + domain + "&URL=" + sigURL;
+ log.info("Updating all services for " + domain + ".");
+ String sql = "select authority_id from authority where authority_uri=?";
+ String updateSQL = "update service_instance set signatureURL = ? where authority_id=?";
+ int authID = -1;
+ PreparedStatement preparedStatement = null;
+ try {
+ preparedStatement = getConnection().prepareStatement(sql);
+ preparedStatement.setString(1,domain);
+ ResultSet results = preparedStatement.executeQuery();
+ if (results.next())
+ authID = results.getInt(1);
+ else {
+ // clean up and return
+ if (preparedStatement != null)
+ preparedStatement.close();
+ return false;
+ }
+ } catch (SQLException e) {
+ log.error(e.getLocalizedMessage());
+ return false;
+ } finally {
+ try {
+ if (preparedStatement != null)
+ preparedStatement.close();
+ } catch (SQLException e) {
+ return false;
+ }
+ }
+
+ preparedStatement = null;
+ int updatedRowCount = -1;
+ try {
+ preparedStatement = getConnection().prepareStatement(updateSQL);
+ preparedStatement.setString(1,sigURL);
+ preparedStatement.setInt(2, authID);
+ updatedRowCount = preparedStatement.executeUpdate();
+ return updatedRowCount > -1;
+ } catch (SQLException e) {
+ log.error(e.getLocalizedMessage());
+ return updatedRowCount > -1;
+ } finally {
+ try {
+ if (preparedStatement != null)
+ preparedStatement.close();
+ } catch (SQLException e) {
+ return updatedRowCount > -1;
+ }
+ }
} else {
- con = "http://mobycentral.icapture.ubc.ca/cgi-bin/updateSignatureURL.cgi?authURI="
- + domain + "&URL=" + sigURL + "&serviceName=" + name;
+ // update 1 service
+ log.info("Updating the service, " + name+ ", for " + domain + ".");
+ String sql = "select authority_id from authority where authority_uri=?";
+ String updateSQL = "update service_instance set signatureURL = ? where authority_id= ? and servicename= ?";
+ int authID = -1;
+ PreparedStatement preparedStatement = null;
+ try {
+ preparedStatement = getConnection().prepareStatement(sql);
+ preparedStatement.setString(1,domain);
+ ResultSet results = preparedStatement.executeQuery();
+ if (results.next())
+ authID = results.getInt(1);
+ else {
+ // clean up and return
+ if (preparedStatement != null)
+ preparedStatement.close();
+ return false;
+ }
+ } catch (SQLException e) {
+ log.error(e.getLocalizedMessage());
+ return false;
+ } finally {
+ try {
+ if (preparedStatement != null)
+ preparedStatement.close();
+ } catch (SQLException e) {
+ return false;
+ }
+ }
+
+ preparedStatement = null;
+ int updatedRowCount = -1;
+ try {
+ preparedStatement = getConnection().prepareStatement(updateSQL);
+ preparedStatement.setString(1,sigURL);
+ preparedStatement.setInt(2, authID);
+ preparedStatement.setString(3,name);
+ updatedRowCount = preparedStatement.executeUpdate();
+ return updatedRowCount == 1;
+ } catch (SQLException e) {
+ log.error(e.getLocalizedMessage());
+ return updatedRowCount == 1;
+ } finally {
+ try {
+ if (preparedStatement != null)
+ preparedStatement.close();
+ } catch (SQLException e) {
+ return updatedRowCount == 1;
+ }
+ }
+
}
- URL url = new URL(con);
- try {
- BufferedReader in = new BufferedReader(new InputStreamReader(url
- .openStream()));
- if (in.readLine().equals("good")) {
- return true;
- }
- } catch (IOException ex) {}
- return false;
-
}
/**
@@ -138,19 +230,55 @@
* @return
*/
private boolean isValidSig(String sigURL) {
- /*final String URL = "(^(http:\\/\\/www\\.|HTTP:\\/\\/www\\.|http:\\/\\/|HTTP:\\/\\/)[\\w]+\\.[\\w].*(\\/\\w+(\\.{1}\\w+)*)$)";
- Pattern p = Pattern.compile(URL);
- Matcher m = p.matcher(sigURL);
- return m.matches();*/
+
try {
URL url = new URL(sigURL);
return true;
} catch (MalformedURLException e) {
-
return false;
}
}
+ private Connection connection = null;
+ private DataSource datasource = null;
+ private Properties props = MobyProperties.SERVICE_INSTANCE_PROPERTIES();;
+
+ private Connection getConnection() {
+ if (this.datasource == null) {
+ // get certain properties from mobycentral.config
+ String serverName = props.get("url") + ":" + props.get("port");// localhost:3306";
+ String mydatabase = (String) props.get("dbname");// "mobyobject";
+ String url = "jdbc:mysql://" + serverName + "/" + mydatabase;
+ String username = (String) props.get("username");// "moby_external";
+ String password = (String) props.get("password");// "";
+ DataSource datasource = setupDataSource(url, username, password);
+ this.datasource = datasource;
+ }
+ try {
+ return this.datasource.getConnection();
+ } catch (SQLException e) {
+ log.error("Error getting connection to db..." + newline + e);
+ return null;
+ }
+
+ }
+
+ private DataSource setupDataSource(String connectURI, String user, String pass) {
+ BasicDataSource ds = new BasicDataSource();
+ try {
+ ds.setLoginTimeout(30);
+ } catch (SQLException e) {
+ log.equals("Couldn't set login timeout " + e.getLocalizedMessage());
+ }
+ ds.setMaxWait(1000 * 60*5);
+ ds.setTimeBetweenEvictionRunsMillis(1000 * 60 * 5);
+ ds.setDriverClassName("com.mysql.jdbc.Driver");
+ ds.setUsername(user);
+ ds.setPassword(pass);
+ ds.setUrl(connectURI);
+ return ds;
+ }
+
private static String filter(String input) {
if (input == null)
return null;
@@ -172,4 +300,9 @@
}
return (filtered.toString());
}
+
+ public static void main(String[] args) throws MalformedURLException {
+ GetSignatureRDFResponse g = new GetSignatureRDFResponse();
+ System.out.println(g.updateMobyCentralDatabase("blah.blah.bah", "http://www.eddie.com/signatureURLs","Echo_test2"));
+ }
}
\ No newline at end of file
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFForm.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFForm.java 2005/09/30 14:48:22 1.4
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFForm.java 2006/10/11 01:54:50 1.5
@@ -7,178 +7,225 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
+import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.discovery.tools.DiscoverSingleton;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.biomoby.client.CentralImpl;
+import org.biomoby.client.ui.graphical.servlet.utilities.ContextLoader;
+import org.biomoby.registry.properties.RegistryOS;
import org.biomoby.shared.Central;
import org.biomoby.shared.MobyException;
+import org.biomoby.shared.Utils;
/**
* @author Eddie Kawas
- * <p>Created for
- * <p>This class was created to ...
- * <p>For questions, comments, or bugs
- * <p>email me at edward.kawas at gmail.com
+ * <p>
+ * Created for
+ * <p>
+ * This class was created to ...
+ * <p>
+ * For questions, comments, or bugs
+ * <p>
+ * email me at edward.kawas at gmail.com
*/
public class GetSignatureRDFForm extends HttpServlet {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- // some useful variables
- private final String newline = System.getProperty("line.separator");
-
- private static final String DOMAIN = "mobycentral.icapture.ubc.ca";
-
- /* (non-Javadoc)
- * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
- */
- protected void doGet(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- // set the content type
- response.setContentType("text/html");
- PrintWriter out = response.getWriter();
-
- // get a list of domains
- Central central = null;
- String[] domains = null;
- // initialize central
- try {
- //TODO - enter the endpoint here
- central = new CentralImpl();
- domains = central.getProviders();
- } catch (MobyException e) {
- out.println("Please try again later.");
- return;
- }
- // sort the array
- Arrays.sort(domains);
- StringBuffer sb = new StringBuffer("");
- for (int x = 0; x < domains.length; x++) {
- sb.append("\t\t<option>" + domains[x] + "</option>" + newline);
- }
-
- String page = "<HTML>"
- + newline
- + "<script language=\"JavaScript\">"
- + newline
- + "<!--"
- + newline
- + "function validate() {"
- + newline
- + "\t// do some validation here"
- + newline
- + "\tthis.details.submit();"
- + newline
- + "}"
- + newline
- + "//-->"
- + newline
- + "</script type=\"text/javascript\">"
- + newline
- + "<HEAD>"
- + newline
- + " <TITLE>Retrieve Your RDF Document</TITLE>"
- + newline
- + "</HEAD>"
- + newline
- + "<meta http-equiv=\"pragma\" content=\"no-cache\">"
- + newline
- + "<BODY BGCOLOR=\"#FDF5E6\">"
- + newline
- + "<H1 ALIGN=\"CENTER\">Retrieve an Updated RDF Document <br>"
- + newline
- + "for your MOBY Service Instance(s) </H1>"
- + newline
- + "<h3 ALIGN=\"left\"> </h3>"
- + newline
- + "<h3 ALIGN=\"left\">This form will allow you to retrieve an updated version of the RDF<br>"
- + newline
- + " document for MOBY Service Instances that you have created. In<br>"
- + newline
- + "addition, you will be able to update the signature url field for your service instance. </h3>"
- + newline
- + "<FORM ACTION=\"http://"
- + DOMAIN
- + "/servlets/forms/getSignatureResponse\" name=\"details\" id=\"form\">"
- + newline
- + " <p>Your Domain:"
- + newline
- + " <select name=\"domain\">"
- + sb.toString()
- + " </select>"
- + newline
- + " <em><strong> *required</strong></em><em><strong><br>"
- + newline
- + " This field is required! </strong></em></p>"
- + newline
- + " <p><BR>"
- + newline
- + " Service Instance Name:"
- + newline
- + " <INPUT NAME=\"serviceName\" TYPE=\"TEXT\" id=\"serviceName\" size=\"82\">"
- + newline
- + " <em>*optional*<br>"
- + newline
- + " <strong>If this field is left blank then an RDF document containing"
- + newline
- + " all of the <br>"
- + newline
- + " service instances created by the selected domain will be returned. </strong></em></p>"
- + newline
- + " <p><BR>"
- + newline
- + " Your Signature URL:"
- + newline
- + " <INPUT NAME=\"sigURL\" TYPE=\"TEXT\" id=\"sigURL\" size=\"82\">"
- + newline
- + " *required<br>"
- + newline
- + " <em><strong>This field indicates the URL from which the RDF that you are about "
- + newline
- + "to receive can be retrieved at a later date (i.e. the place where you"
- + newline
- + "are going to save the output of this script)</strong></em></p>"
- + newline + " <blockquote> </blockquote>" + newline
- + " <p> <INPUT TYPE=\"SUBMIT\">" + newline + "</p>"
- + newline + "</FORM>" + newline + "</BODY>" + newline
- + "</HTML>" + newline;
-
- out.println(page);
- return;
- }
-
- /* (non-Javadoc)
- * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
- */
- protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1)
- throws ServletException, IOException {
- doGet(arg0, arg1);
- }
-
- public static void main(String[] args) {
- Central central = null;
- String[] domains = null;
- // initialize central
- try {
- central = new CentralImpl();
- domains = central.getProviders();
- } catch (MobyException e) {
- e.printStackTrace();
- return;
- }
- // sort the array
- Arrays.sort(domains);
- StringBuffer sb = new StringBuffer("");
- for (int x = 0; x < domains.length; x++) {
- sb.append("\t\t<option>" + domains[x] + "</option>\n");
- }
- System.out.println(sb.toString());
- }
+ private static Log log = LogFactory.getLog(GetSignatureRDFForm.class);
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ // some useful variables
+ private final String newline = System.getProperty("line.separator");
+
+ private static String DOMAIN = "mobycentral.icapture.ubc.ca:8090/moby/";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest,
+ * javax.servlet.http.HttpServletResponse)
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ DOMAIN = request.getServerName() + ":" + request.getServerPort() + request.getContextPath()
+ + "/";
+
+ // set the content type
+ response.setContentType("text/html");
+ PrintWriter out = response.getWriter();
+
+ // get a list of domains
+ Central central = null;
+ String[] domains = null;
+ // initialize central
+ try {
+ String registryURL = null;
+ String registryNamespace = null;
+
+ // are they set in the system?
+ registryURL = System.getProperty("MOBY_SERVER");
+ registryNamespace = System.getProperty("MOBY_URI");
+
+ // if we didnt set them check the environment
+ if (registryURL == null) {
+ Map map = RegistryOS.getEnv();
+ if (!map.isEmpty()) {
+ registryURL = (String) map.get("MOBY_SERVER");
+ registryNamespace = (String) map.get("MOBY_URI");
+ }
+ }
+
+ log.info("Retrieving providers from URL: "
+ + (registryURL == null ? CentralImpl.DEFAULT_ENDPOINT : registryURL)
+ + " URI: "
+ + (registryNamespace == null ? CentralImpl.DEFAULT_NAMESPACE
+ : registryNamespace));
+ if (registryURL == null) {
+ // use default registry, since we dont have a local one
+ central = new CentralImpl();
+ } else if (registryNamespace == null) {
+ // use default namespace since one isnt defined
+ central = new CentralImpl(registryURL);
+ } else {
+ // use defined url and namespacce
+ central = new CentralImpl(registryURL, registryNamespace);
+ }
+ domains = central.getProviders();
+ } catch (MobyException e) {
+ out.println("Please try again later.");
+ log.error(Utils.format(newline+"There was a problem extracting all of the providers:"+newline+e.getLocalizedMessage(), 3), e);
+ return;
+ }
+ // sort the array
+ Arrays.sort(domains);
+ StringBuffer sb = new StringBuffer("");
+ for (int x = 0; x < domains.length; x++) {
+ sb.append("\t\t<option>" + domains[x] + "</option>" + newline);
+ }
+
+ String page = "<HTML>"
+ + newline
+ + "<script language=\"JavaScript\">"
+ + newline
+ + "<!--"
+ + newline
+ + "function validate() {"
+ + newline
+ + "\t// do some validation here"
+ + newline
+ + "\tthis.details.submit();"
+ + newline
+ + "}"
+ + newline
+ + "//-->"
+ + newline
+ + "</script type=\"text/javascript\">"
+ + newline
+ + "<HEAD>"
+ + newline
+ + " <TITLE>Retrieve Your RDF Document</TITLE>"
+ + newline
+ + "</HEAD>"
+ + newline
+ + "<meta http-equiv=\"pragma\" content=\"no-cache\">"
+ + newline
+ + "<BODY BGCOLOR=\"#FDF5E6\">"
+ + newline
+ + "<H1 ALIGN=\"CENTER\">Retrieve an Updated RDF Document <br>"
+ + newline
+ + "for your MOBY Service Instance(s) </H1>"
+ + newline
+ + "<h3 ALIGN=\"left\"> </h3>"
+ + newline
+ + "<h3 ALIGN=\"left\">This form will allow you to retrieve an updated version of the RDF<br>"
+ + newline
+ + " document for MOBY Service Instances that you have created. In<br>"
+ + newline
+ + "addition, you will be able to update the signature url field for your service instance. </h3>"
+ + newline
+ + "<FORM ACTION=\"http://"
+ + DOMAIN
+ + "forms/getSignatureResponse\" name=\"details\" id=\"form\">"
+ + newline
+ + " <p>Your Domain:"
+ + newline
+ + " <select name=\"domain\">"
+ + sb.toString()
+ + " </select>"
+ + newline
+ + " <em><strong> *required</strong></em><em><strong><br>"
+ + newline
+ + " This field is required! </strong></em></p>"
+ + newline
+ + " <p><BR>"
+ + newline
+ + " Service Instance Name:"
+ + newline
+ + " <INPUT NAME=\"serviceName\" TYPE=\"TEXT\" id=\"serviceName\" size=\"82\">"
+ + newline
+ + " <em>*optional*<br>"
+ + newline
+ + " <strong>If this field is left blank then an RDF document containing"
+ + newline
+ + " all of the <br>"
+ + newline
+ + " service instances created by the selected domain will be returned. </strong></em></p>"
+ + newline
+ + " <p><BR>"
+ + newline
+ + " Your Signature URL:"
+ + newline
+ + " <INPUT NAME=\"sigURL\" TYPE=\"TEXT\" id=\"sigURL\" size=\"82\">"
+ + newline
+ + " *required<br>"
+ + newline
+ + " <em><strong>This field indicates the URL from which the RDF that you are about "
+ + newline + "to receive can be retrieved at a later date (i.e. the place where you"
+ + newline + "are going to save the output of this script)</strong></em></p>"
+ + newline + " <blockquote> </blockquote>" + newline
+ + " <p> <INPUT TYPE=\"SUBMIT\">" + newline + "</p>" + newline
+ + "</FORM>" + newline + "</BODY>" + newline + "</HTML>" + newline;
+
+ out.println(page);
+ return;
+ }
+
+ @Override
+ public void init() throws ServletException {
+ super.init();
+ ContextLoader cLoader = null;
+ try {
+ cLoader = (ContextLoader) DiscoverSingleton.find(Class
+ .forName((String) ContextLoader.class.getCanonicalName()), Class.forName(
+ (String) ContextLoader.class.getCanonicalName()).getName());
+ log
+ .info((cLoader == null ? "ContextLoader is null and is therefore not loaded. This is BAD!"
+ : "ContextLoader has loaded successfully."));
+ } catch (Exception e) {
+ log.warn("ContextLoader is null and is therefore not loaded. This is BAD!"
+ + System.getProperty("line.separator") + e.getMessage());
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest,
+ * javax.servlet.http.HttpServletResponse)
+ */
+ protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1)
+ throws ServletException, IOException {
+ doGet(arg0, arg1);
+ }
}
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/RDFAgentValidator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/RDFAgentValidator.java 2006/05/24 18:48:31 1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/RDFAgentValidator.java 2006/10/11 01:54:50 1.3
@@ -7,17 +7,16 @@
import java.net.URLDecoder;
import java.util.Properties;
-import javax.naming.Context;
-import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.discovery.tools.DiscoverSingleton;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.biomoby.client.ui.graphical.servlet.utilities.ContextLoader;
import org.biomoby.registry.properties.MobyProperties;
-import org.biomoby.registry.rdfagent.verifier.Main;
/*
* Created on Jan 14, 2005 <p>
@@ -46,44 +45,17 @@
public final void init() throws ServletException {
// super.init();
- // try to load environment variables set in context.xml
+ ContextLoader cLoader = null;
try {
- Context c = new InitialContext();
-
- try {
- String MOBY_CENTRAL_CONFIG = null;
- MOBY_CENTRAL_CONFIG = (String) c.lookup("java:comp/env/MOBY_CENTRAL_CONFIG");
- if (MOBY_CENTRAL_CONFIG != null && !MOBY_CENTRAL_CONFIG.equals("")) {
- // set MOBY_CENTRAL_CONFIG
- log.info("init(setting MOBY_CENTRAL_CONFIG)");
- System.setProperty("MOBY_CENTRAL_CONFIG", MOBY_CENTRAL_CONFIG);
- }
-
- } catch (Exception ex) {
- }
- try {
- String MOBY_SERVER = null;
- MOBY_SERVER = (String) c.lookup("java:comp/env/MOBY_SERVER");
- if (MOBY_SERVER != null && !MOBY_SERVER.equals("")) {
- // set MOBY_SERVER
- log.info("init(setting MOBY_SERVER)");
- System.setProperty("MOBY_SERVER", MOBY_SERVER);
- }
- } catch (Exception ex) {
- }
-
- try {
- String MOBY_URI = null;
- MOBY_URI = (String) c.lookup("java:comp/env/MOBY_URI");
- if (MOBY_URI != null && !MOBY_URI.equals("")) {
- // set MOBY_URI
- log.info("init(setting MOBY_URI)");
- System.setProperty("MOBY_URI", MOBY_URI);
- }
- } catch (Exception ex) {
- }
-
+ cLoader = (ContextLoader) DiscoverSingleton.find(Class
+ .forName((String) ContextLoader.class.getCanonicalName()), Class.forName(
+ (String) ContextLoader.class.getCanonicalName()).getName());
+ log
+ .warn((cLoader == null ? "ContextLoader is null and is therefore not loaded. This is BAD!"
+ : "ContextLoader has loaded successfully."));
} catch (Exception e) {
+ log.warn("ContextLoader is null and is therefore not loaded. This is BAD!"
+ + System.getProperty("line.separator") + e.getStackTrace());
}
}
@@ -122,8 +94,8 @@
return;
}
Process p;
-
- String[] com = new String[] { rdfagent, "-test", url };
+ //TODO may need to place JAVA_HOME in the mobycentral part of the config files.
+ String[] com = new String[] { "java","-DRDFagent.home="+rdfagent,"-jar", rdfagent+"/RDFagent.jar", "-test", url };
p = Runtime.getRuntime().exec(com);
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
StringBuffer sb = new StringBuffer();
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/LSID_ResolverClient.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/LSID_ResolverClient.java 2006/08/30 17:11:25 1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/LSID_ResolverClient.java 2006/10/11 01:54:50 1.2
@@ -108,19 +108,19 @@
String str = resolveLSID(lsid_to_use, "soap");
return str;
} catch (MobyException e) {
- log.error(e);
+ log.debug("Couldn't resolve " + lsid_to_use + " to metadata using SOAP.");
}
try {
String str = resolveLSID(lsid_to_use, "http");
return str;
} catch (MobyException e) {
- log.error(e);
+ log.debug("Couldn't resolve " + lsid_to_use + " to metadata using HTTP.");
}
try {
String str = resolveLSID(lsid_to_use, "ftp");
return str;
} catch (MobyException e) {
- log.error(e);
+ log.debug("Couldn't resolve " + lsid_to_use + " to metadata using FTP.");
}
return "Couldn't resolve your lsid. I tried the protocols SOAP, HTTP, and FTP. If we are missing one, let us know.";
}
@@ -131,19 +131,19 @@
String str = resolveLSID2Data(lsid_to_use, "soap");
return str;
} catch (MobyException e) {
- log.error(e);
+ log.debug("Couldn't resolve " + lsid_to_use + " to data using SOAP.");
}
try {
String str = resolveLSID2Data(lsid_to_use, "http");
return str;
} catch (MobyException e) {
- log.error(e);
+ log.debug("Couldn't resolve " + lsid_to_use + " to data using HTTP.");
}
try {
String str = resolveLSID2Data(lsid_to_use, "ftp");
return str;
} catch (MobyException e) {
- log.error(e);
+ log.debug("Couldn't resolve " + lsid_to_use + " to data using FTP.");
}
return "Couldn't resolve your lsid to Data.";
}
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/LSIDComplete.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/LSIDComplete.java 2006/08/30 17:11:25 1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/LSIDComplete.java 2006/10/11 01:54:50 1.2
@@ -21,8 +21,10 @@
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
+import org.apache.commons.discovery.tools.DiscoverSingleton;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.biomoby.client.ui.graphical.servlet.utilities.ContextLoader;
import org.biomoby.registry.properties.MobyProperties;
/*
@@ -33,6 +35,7 @@
/**
* @author Eddie Kawas
*/
+ at SuppressWarnings("unchecked")
public class LSIDComplete extends HttpServlet {
/**
@@ -45,14 +48,33 @@
final private String newline = System.getProperty("line.separator");
private Map datas = Collections.synchronizedMap(new HashMap());
+
public void init() throws ServletException {
super.init();
+
+
+ ContextLoader cLoader = null;
+ try {
+ cLoader = (ContextLoader) DiscoverSingleton.find(Class
+ .forName((String) ContextLoader.class.getCanonicalName()), Class.forName(
+ (String) ContextLoader.class.getCanonicalName()).getName());
+ log
+ .warn((cLoader == null ? "ContextLoader is null and is therefore not loaded. This is BAD!"
+ : "ContextLoader has loaded successfully."));
+ } catch (Exception e) {
+ log.warn("ContextLoader is null and is therefore not loaded. This is BAD!"
+ + System.getProperty("line.separator") + e.getStackTrace());
+ }
+
log.debug("Initializing the Timer that will invoke the StatWriter");
Timer timer = new Timer();
timer.scheduleAtFixedRate(new StatWriter(this), new java.util.Date(), 1000 * 60 * 60);
}
+ // an array of properties objects created initialized once for more efficient running
+ private Properties[] properties = new Properties[]{null,null, null, null};
+
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String lsid = filter(request.getParameter("lsid"));
@@ -74,20 +96,24 @@
String object = parts[4];
Properties p = null;
// check if the 3rd component is biomoby.org
- if (parts[2].equalsIgnoreCase("biomoby.org")
+ if ((parts[2].equalsIgnoreCase("biomoby.org") || parts[2].equalsIgnoreCase(request.getServerName()))
&& parts[0].equalsIgnoreCase("urn")
&& parts[1].equalsIgnoreCase("lsid")) {
// check if they are typing in
// namespacetype
if (parts[3].equals("namespacetype")) {
- p = MobyProperties.NAMESPACE_PROPERTIES();
+ if (properties[0] == null)
+ properties[0] = MobyProperties.NAMESPACE_PROPERTIES();
+ p = properties[0];
String lsids = getLSIDs(p, object, "namespace");
if (!lsids.equals(""))
lsid = lsids;
}
// objectclass
else if (parts[3].equals("objectclass")) {
- p = MobyProperties.OBJECT_PROPERTIES();
+ if (properties[1] == null)
+ properties[1] = MobyProperties.OBJECT_PROPERTIES();
+ p = properties[1];
String lsids = getLSIDs(p, object, "object");
if (!lsids.equals("")) {
lsid = lsids;
@@ -96,7 +122,9 @@
}
// servicetype
else if (parts[3].equals("servicetype")) {
- p = MobyProperties.SERVICE_PROPERTIES();
+ if (properties[2] == null)
+ properties[2] = MobyProperties.SERVICE_PROPERTIES();
+ p = properties[2];
String lsids = getLSIDs(p, object, "service");
if (!lsids.equals(""))
lsid = lsids;
@@ -104,7 +132,9 @@
// serviceinstance
else if (parts[3].equals("serviceinstance")) {
// weird case, because object is authURI,servicename
- p = MobyProperties.SERVICE_INSTANCE_PROPERTIES();
+ if (properties[3] == null)
+ properties[3] = MobyProperties.SERVICE_INSTANCE_PROPERTIES();
+ p = properties[3];
String lsids = getLSIDs(p, object, "service_instance");
if (!lsids.equals(""))
lsid = lsids;
More information about the MOBY-guts
mailing list