XRD xrd = tmpXRDS.getDescriptorAt(0);
xrdsOut.add(xrd);
ServerStatus sstat = xrd.getServerStatus();
Status stat;
if (sstat == null) {
// compatibility: if no ServerStatus, look for Status
stat = xrd.getStatus();
}
else {
stat = new Status(sstat.getCode(), sstat.getText());
xrd.setStatus(stat);
}
if (stat == null)
throw makeResolutionException(xrdsOut, query, Status.INVALID_XRDS, "Missing ServerStatus or Status element in Redirect XRD");
if (!stat.getCode().equals(Status.SUCCESS)) {
throw new PartialResolutionException(xrdsOut);
}
// check the basic properties of the descriptor
if (!xrd.isValid()) {
xrd.setStatus(new Status(Status.UNEXPECTED_RESPONSE, "XRD is not valid (stale?)"));
throw new PartialResolutionException(xrdsOut);
}
String err = verifyRedirectXRD(xrd, parent);
if (err != null) {
xrd.setStatus(new Status(Status.REDIRECT_VERIFY_FAILED, err));
throw new PartialResolutionException(xrdsOut);
}
// copy parent Status cid attribute if present
stat.setCID(xrd.getCanonicalID() == null? Status.CID_ABSENT : parent.getStatus().getCID());
// copy parent Status ceid attribute (without checking if present since it is supposed to be "off" for
// non-final XRD, and we don't know whether this is a final XRD.)
stat.setCEID(parent.getStatus().getCEID());
try {
if (xrd.getNumRedirects() > 0) {
log.info("fetchRedirectXRDS - XRD at URI(" + uri + ") contains Redirect(s), following..");
tmpXRDS = processRedirects(qxri, xrd, flags, state);