log.debug("processProxyRequest - sXRI is null or empty");
sendResponse(response, HTTP_ERROR_CONTENT_TYPE, "INVALID_QXRI(code=211): null or empty", null);
return;
}
XRI oXRI = null;
try {
oXRI = XRI.fromURINormalForm(qxri);
}
catch (XRIParseException oEx) {
// log and send a 404
log.warn("Error constructing XRI: " + qxri + ", " + oEx);
sendResponse(response,HTTP_ERROR_CONTENT_TYPE, "INVALID_QXRI(code=211): "+oEx.getMessage(),null);
return;
}
// defaults if resolution media type is null
TrustType trustType = new TrustType();
boolean refs = true;
boolean sep = true;
String tempStr = null;
if(resMediaType != null) {
tempStr = resMediaType.getParam(MimeType.PARAM_REFS);
if(tempStr != null && tempStr.equals("false"))
refs = false;
tempStr = resMediaType.getParam(MimeType.PARAM_SEP);
if(tempStr != null && tempStr.equals("false"))
sep = false;
tempStr = resMediaType.getParam(MimeType.PARAM_TRUST);
if (tempStr != null) {
try {
trustType.setType(tempStr);
}
catch (IllegalTrustTypeException e) {
sendResponse(response, HTTP_ERROR_CONTENT_TYPE, "INVALID_RESOLUTION_MEDAIA_TYPE(code=212): " + resMediaType, null);
return;
}
}
}
// set the request preferences on the resolver before querying.
XRDS xrds = null;
XRD xrd = null;
try
{
if (sep) {
if (resMediaType == null) {
// see section 7.6 for special redirect rule
ArrayList uris = resolver.resolveSEPToURIList(oXRI.toString(), trustType, serviceType, serviceMediaType, refs);
if (uris == null || uris.size() == 0) {
sendResponse(response, HTTP_ERROR_CONTENT_TYPE, "SEP_NOT_FOUND(code=241): no url found", null);
return;
}
String s = (String) uris.get(0);
log.trace("Sending redirect to '" + s + "'");
response.sendRedirect(s);
}
else if (resMediaType.isType(MimeType.URI_LIST)) {
String text = resolver.resolveSEPToTextURIList(oXRI.toString(), trustType, serviceType, serviceMediaType, refs);
if (text.length() <= 0)
sendResponse(response, HTTP_ERROR_CONTENT_TYPE, "SEP_NOT_FOUND(code=241): no url found", null);
else
sendResponse(response, resMediaType.getType(), text, null);
}