use of org.apache.jena.irix.IRIException in project jena by apache.
the class GraphTarget method xresolve.
/**
* Resolve URI. Calculate a base URI from the dataset URI and resolve uri against that.
*/
private static String xresolve(String uriStr, HttpAction action) {
// Strictly, a bit naughty on the URI resolution, but more sensible.
// Make the base the URI of the dataset.
// Strictly, the base includes service and query string but that is unhelpful.
// wholeRequestURL(request);
IRIx uri;
try {
uri = IRIx.create(uriStr);
if (uri.isReference())
return uri.str();
} catch (IRIException ex) {
FmtLog.warn(Fuseki.actionLog, "Bad URI: '" + uriStr);
ServletOps.errorBadRequest("Bad IRI: " + uriStr + " : " + ex.getMessage());
return null;
}
String baseStr = action.getRequestRequestURL().toString();
Endpoint ep = action.getEndpoint();
if (!ep.isUnnamed() && baseStr.endsWith(ep.getName())) {
// Remove endpoint name
baseStr = baseStr.substring(0, baseStr.length() - ep.getName().length());
}
// Make sure it ends in "/", treating the dataset as a container.
if (!baseStr.endsWith("/"))
baseStr = baseStr + "/";
try {
IRIx base = IRIx.create(baseStr);
IRIx uri2 = base.resolve(uri);
if (!uri2.isReference()) {
FmtLog.warn(Fuseki.actionLog, "Bad URI (after resolving): '" + uriStr);
ServletOps.errorBadRequest("Bad IRI: " + uriStr);
}
return uri2.str();
} catch (IRIException ex) {
ServletOps.errorBadRequest("Bad IRI: " + uriStr + " : " + ex.getMessage());
return null;
}
}
Aggregations