*/
public boolean lookup(LookupState ls, LookupResult lr)
throws ProtocolException
{
if ( ls.isDirectory() ) { // we are not a directory, bail out
Request req = (Request)ls.getRequest();
String locstate = (String)req.getState(STATE_CONTENT_LOCATION);
if (locstate == null) {
lr.setTarget(null);
return true;
}
}
ResourceFrame frames[] = getFrames();
if (frames != null) {
for (int i = 0 ; i < frames.length ; i++) {
if (frames[i] == null) {
continue;
}
if (frames[i].lookup(ls,lr)) {
return true;
}
}
}
if ( ls.hasMoreComponents() ) {
// We are not a container resource, and we don't have children:
lr.setTarget(null);
return false;
} else {
//we are done! try to find the negotiated one...
RequestInterface reqi = ls.getRequest();
ResourceReference selected;
Request request = (Request) reqi;
// Run content negotiation now:
// The PUT is special, we negotiate with ETag (if present) or
// using the metainformation about the PUT entity.
String method = request.getMethod ();
try {
if (method.equals("PUT")) {
selected = negotiatePut(request);
} else {
selected = negotiate(request);
}
} catch (ResourceException ex) {
// the failure will be processed in perform
return false;
}
if (selected != null) {
try {
FramedResource resource =
(FramedResource) selected.unsafeLock();
resource.lookup(ls, lr);
} catch (InvalidResourceException ex) {
// the failure will be processed in perform
} finally {
selected.unlock();
}
}
request.setState(STATE_NEG, selected);
// fake now, we handle the process to have a two-level processing
// just to add the Vary: header
lr.setTarget(getResourceReference());
return true;
}