*
* @param request discovery request.
*/
private static void queryDirectly(MDDiscoveryRequest request)
{
FeedMetaDataHolder holder = request.getHolder();
if (request.isDirectDiscoveryComplete() || holder.getXmlURL() != null) return;
if (LOG.isLoggable(Level.FINE))
{
LOG.fine("Direct discovery started: URL=" + request.getUrl());
}
DirectDiscoverer dd = new DirectDiscoverer();
String failureMessage = null;
try
{
DiscoveryResult res = dd.discover(request.getUrl());
if (res != null)
{
URL link = res.getLink();
if (link != null)
{
holder.setXmlURL(link);
holder.setInvalid(false);
}
}
request.setDirectDiscoveryComplete(true);
} catch (UrlDiscovererException e)
{
Throwable cause = e.getCause();
failureMessage = causeToFailureMessage(cause);
if (failureMessage != null)
{
request.setDirectDiscoveryComplete(true);
// We can't set invalid flag here because it is very brief check
// and we can count only on positive result.
} else
{
LOG.log(Level.FINE, "Direct discovery failed temporary.", e);
}
} catch (IllegalArgumentException e)
{
// This exception is thrown by parser when it is unable to find root element of
// the feed. Usually it happens when we give it non-xml file as input. Here we mark direct
// discovery as complete as it doesn't make any sense to continue hitting the same exception.
request.setDirectDiscoveryComplete(true);
}
if (request.isDirectDiscoveryComplete() && LOG.isLoggable(Level.FINE))
{
LOG.fine("Direct discovery finished: URL=" + request.getUrl() +
(holder.getXmlURL() != null ? " Discovered" : " Undiscovered") +
(failureMessage != null ? " (" + failureMessage + ")" : ""));
}
}