package ca.uhnresearch.pughlab.tracker.restlets;

import org.restlet.Context;
import org.restlet.Request;
import org.restlet.Response;
import org.restlet.Restlet;
import org.restlet.data.Status;
import org.restlet.routing.Filter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DefaultingFilter extends Filter {
	
	private final Logger logger = LoggerFactory.getLogger(getClass());

	private String defaultPath = "/index.html";
	
	public DefaultingFilter(Context context, Restlet next) {
		super(context, next);
	}
	
	@Override
	protected int doHandle (Request request, Response response) {
		logger.debug("doHandle FILTER: " + request.getResourceRef().getPath());
		int result = super.doHandle(request, response);
		if (response.getStatus().equals(Status.CLIENT_ERROR_NOT_FOUND)) {
			response.setStatus(Status.SUCCESS_OK);
			String path = request.getResourceRef().getPath();
			
			if (! defaultPath.equals(path)) {
				request.getResourceRef().setPath(defaultPath);
				result = super.doHandle(request, response);
			}
		}
		return result;
	}
	
	/**
	 * @return the defaultPath
	 */
	public String getDefaultPath() {
		return defaultPath;
	}

	/**
	 * @param rewrites the defaultPath to set
	 */
	public void setDefaultPath(String defaultPath) {
		this.defaultPath = defaultPath;
	}
}

@@ -907,17 +907,20 @@
 %09%09if (! 
-d
+getD
 efaultPa
@@ -921,16 +921,18 @@
 aultPath
+()
 .equals(
@@ -977,17 +977,20 @@
 setPath(
-d
+getD
 efaultPa
@@ -991,16 +991,18 @@
 aultPath
+()
 );%0A%09%09%09%09r

Make sure we use an accessor rather than a private var for overriding