[MOBY-guts] biomoby commit
Paul Gordon
gordonp at dev.open-bio.org
Tue Jun 9 19:01:19 UTC 2009
gordonp
Tue Jun 9 15:01:19 EDT 2009
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared
In directory dev.open-bio.org:/tmp/cvs-serv19780/src/main/org/biomoby/shared
Modified Files:
LSIDResolver.java
Log Message:
Logging support, fallback in case DNS not accessible, and temporary reliance on Apache XPath rather than JAX-T due to Google App Engine bug
moby-live/Java/src/main/org/biomoby/shared LSIDResolver.java,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/LSIDResolver.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/shared/LSIDResolver.java 2008/06/30 21:22:08 1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/LSIDResolver.java 2009/06/09 19:01:19 1.3
@@ -14,6 +14,7 @@
import java.io.*;
import java.net.URL;
import java.util.*;
+import java.util.logging.*;
import java.util.regex.*;
/**
@@ -47,12 +48,17 @@
public static final String LSID_HTTP_NAMESPACE = "http://www.omg.org/LSID/2003/AuthorityServiceHTTPBindings";
public static final String LSID_SOAP_NAMESPACE = "http://www.omg.org/LSID/2003/AuthorityServiceSOAPBindings";
public static final String LSID_WSDL_NAMESPACE = "http://www.omg.org/LSID/2003/Standard/WSDL";
+ private boolean warnedOfDNSAccess = false;
+
+ private static Logger logger = Logger.getLogger(LSIDResolver.class.getName());
private XPath xPath;
private DocumentBuilder docBuilder;
public LSIDResolver(){
- XPathFactory xPathFactory = XPathFactory.newInstance();
+ //PG Temporarily use xalan while Google App Engine XPath bug exists
+ //XPathFactory xPathFactory = XPathFactory.newInstance();
+ XPathFactory xPathFactory = new org.apache.xpath.jaxp.XPathFactoryImpl();
try{
xPath = xPathFactory.newXPath();
xPath.setNamespaceContext(new NamespaceContextImpl());
@@ -81,7 +87,22 @@
"cannot extract the lookup authority.");
}
- Record[] records = new Lookup(SRV_PREFIX + lsidAuthority, Type.SRV).run();
+ Record[] records = null;
+ try{
+ records = new Lookup(SRV_PREFIX + lsidAuthority, Type.SRV).run();
+ } catch(Throwable t){
+ // If we can't access DNA resources (e.g. in a restricted environment
+ // such as an applet or Google App Engine), do a last ditch guess
+ // as to the location of the server rather than using the second well-known rule
+ if(!warnedOfDNSAccess){
+ warnedOfDNSAccess = true;
+ logger.log(Level.WARNING, "Cannot access DNS SRV records for LSID resolution, will use hostname directly", t);
+ }
+ return new URL("http",
+ lsidAuthority,
+ 80,
+ AUTHORITY_WSDL_LOCATION);
+ }
if(records == null || records.length == 0){
throw new Exception("While trying to use LSID resolution's Second Well-Known Rule: " +
" The authority for the lsid (" + lsidAuthority +
@@ -281,7 +302,7 @@
NodeList addrs = es[0].getElementsByTagNameNS(MobyPrefixResolver.HTTP_NAMESPACE, "address");
if(addrs == null || addrs.getLength() == 0){
throw new Exception("Could not find the definition of the HTTP address within " +
- "the WSDL's LSIDMetadataHTTPBinding spec");
+ "the WSDL's LSIDMetadataHTTPBinding spec, maybe a non-existant LSID? (" + lsid + ")");
}
else{
// baseURL is a bad assumption, as the node may be from an import in another location
More information about the MOBY-guts
mailing list