if ( debug )
printNegotiationState ("After Q selection:", states) ;
if ( qmax == REQUIRED_QUALITY ) {
Reply reply = request.makeReply(HTTP.NOT_ACCEPTABLE) ;
HtmlGenerator g = new HtmlGenerator("No acceptable");
g.append("<P>The resource cannot be served according to the "
+ "headers sent</P>");
reply.setStream (g) ;
throw new HTTPException (reply) ;
} else if ( states.size() == 1 ) {
return ((VariantState) states.elementAt(0)).getResource() ;
} else {
// Respond with multiple choice (for the time being, there should
// be a parameter to decide what to do.
Reply reply = request.makeReply(HTTP.MULTIPLE_CHOICE) ;
HtmlGenerator g = new HtmlGenerator ("Multiple choice for "+
resource.getIdentifier()) ;
g.append ("<ul>") ;
for (int i = 0 ; i < states.size() ; i++) {
VariantState state = (VariantState) states.elementAt(i) ;
String name = null;
ResourceReference rr = state.getResource();
try {
name = rr.unsafeLock().getIdentifier();
g.append ("<li>"
+ "<a href=\"" + name + "\">" + name + "</a>"
+ " Q= " + state.getQ()) ;
} catch (InvalidResourceException ex) {
//FIXME
} finally {