if (ls.countRemainingComponents() == 1)
rr = dresource.createResource(name, request);
else
rr = dresource.createDirectoryResource(name);
if (rr == null) {
Reply error =
request.makeReply(HTTP.UNSUPPORTED_MEDIA_TYPE);
error.setContent(
"Failed to create resource "+
name +" : "+
"Unable to create the appropriate file:"+
request.getURLPath()+
" this media type is not supported");
throw new HTTPException (error);
}
} else if (rr == null) {
Reply error = request.makeReply(HTTP.FORBIDDEN) ;
error.setContent("You are not allowed to create resource "+
name +" : "+
dresource.getIdentifier()+
" is not extensible.");
throw new HTTPException (error);
}
}
}
if ( super.lookup(ls, lr) ) {
if ( ! ls.isDirectory() && ! ls.isInternal() ) {
// The directory lookup URL doesn't end with a slash:
Request request = (Request)ls.getRequest() ;
if ( request == null ) {
lr.setTarget(null);
return true;
}
URL url = null;
try {
if ((request != null ) &&
request.hasState(Request.ORIG_URL_STATE)) {
URL oldurl;
oldurl = (URL)request.getState(Request.ORIG_URL_STATE);
url = new URL(oldurl, oldurl.getFile() + "/");
} else {
url = (ls.hasRequest()
? getURL(request)
: new URL(getServer().getURL(),
resource.getURLPath()));
}
} catch (MalformedURLException ex) {
getServer().errlog(this, "unable to build full URL.");
throw new HTTPException("Internal server error");
}
String msg = "Invalid requested URL: the directory resource "+
" you are trying to reach is available only through "+
" its full URL: <a href=\""+
url + "\">" + url + "</a>.";
if ( getRelocateFlag() ) {
// Emit an error (with reloc if allowed)
Reply reloc = request.makeReply(HTTP.FOUND);
reloc.setContent(msg) ;
reloc.setLocation(url);
lr.setTarget(null);
lr.setReply(reloc);
return true;
} else {
Reply error = request.makeReply(HTTP.NOT_FOUND) ;
error.setContent(msg) ;
lr.setTarget(null);
lr.setReply(error);
return true;
}
} else if ( ! ls.isInternal() ) {