protected XRDS fetchRedirectXRDS(URI uri, XRD parent, XRI qxri, ResolverFlags flags, ResolverState state)
throws PartialResolutionException
{
XRDS xrdsOut = new XRDS();
String query = qxri.toURINormalForm();
xrdsOut.setRedirect(uri.toString());
XRDS tmpXRDS = null;
try {
log.info("fetchRedirectXRDS - fetching from URI(" + uri + ")");
InputStream in = getDataFromURI(uri, query, flags, state);
log.info("fetchRedirectXRDS - reading content from URI(" + uri + ")");
tmpXRDS = readXRDS(in);
log.debug("fetchRedirectXRDS - got XRDS = " + tmpXRDS.toString());
} catch (IOException e) {
log.error("fetchRedirectXRDS - got IOException from URI " + uri);
throw makeResolutionException(xrdsOut, query, Status.NETWORK_ERROR, "Networking error encountered");
} catch (Exception e) {
log.error("fetchRedirectXRDS - unexpected error: " + e);
e.printStackTrace();
throw makeResolutionException(xrdsOut, query, Status.AUTH_RES_ERROR, e.getMessage());
}
//// sanity checks
// there should be exactly one child element
if (tmpXRDS.getNumChildren() != 1 || !tmpXRDS.isXRDAt(0)) {
throw makeResolutionException(xrdsOut, query, Status.INVALID_XRDS, "Invalid XRDS document: single XRD element expected");
}
if (!tmpXRDS.isXRDAt(0))
throw makeResolutionException(xrdsOut, query, Status.INVALID_XRDS, "Authority XRDS document should not contain XRDS element");
XRD xrd = tmpXRDS.getDescriptorAt(0);
xrdsOut.add(xrd);
ServerStatus sstat = xrd.getServerStatus();
Status stat;