package com.sixsq.slipstream.resource;

/*
 * +=================================================================+
 * SlipStream Server (WAR)
 * =====
 * Copyright (C) 2013 SixSq Sarl (sixsq.com)
 * =====
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * -=================================================================-
 */

import org.restlet.Context;
import org.restlet.resource.Directory;
import org.restlet.routing.Filter;
import org.restlet.routing.Router;
import org.restlet.routing.Template;
import org.restlet.routing.TemplateRoute;
import org.restlet.security.Authenticator;
import org.restlet.security.Authorizer;

import com.sixsq.slipstream.authn.CookieAuthenticator;
import com.sixsq.slipstream.authz.ReportsAuthorizer;
import com.sixsq.slipstream.authz.SuperEnroler;
import com.sixsq.slipstream.configuration.Configuration;
import com.sixsq.slipstream.exceptions.ConfigurationException;
import com.sixsq.slipstream.filter.ReportDecorator;

public class ReportRouter extends Router {

	public ReportRouter(Context context) throws ConfigurationException {
		super(context);

		String reportsLocation = Configuration.getInstance().getProperty(
		"slipstream.reports.location");

		Authorizer authorizer = new ReportsAuthorizer();
		Authenticator authenticator = new CookieAuthenticator(getContext());
		authenticator.setNext(authorizer);
		authenticator.setEnroler(new SuperEnroler());

//		authorizer.setNext(new Directory(getContext(), "file://" + reportsLocation));
//		TemplateRoute route = attach("/{uuid}/{file}.tgz", authorizer);
//		route.getTemplate().setMatchingMode(Template.MODE_EQUALS);
		

		ResultsDirectory directory = new ResultsDirectory(getContext(),
				"file://" + reportsLocation);
		Filter decorator = new ReportDecorator();
		decorator.setNext(directory);
		authorizer.setNext(decorator);
		attach("", authenticator);
	}

}

@@ -863,47 +863,8 @@
 xt;%0A
-import org.restlet.resource.Directory;%0A
 impo
@@ -933,87 +933,8 @@
 er;%0A
-import org.restlet.routing.Template;%0Aimport org.restlet.routing.TemplateRoute;%0A
 impo
@@ -1790,225 +1790,8 @@
 );%0A%0A
-//%09%09authorizer.setNext(new Directory(getContext(), %22file://%22 + reportsLocation));%0A//%09%09TemplateRoute route = attach(%22/%7Buuid%7D/%7Bfile%7D.tgz%22, authorizer);%0A//%09%09route.getTemplate().setMatchingMode(Template.MODE_EQUALS);%0A%09%09%0A%0A
 %09%09Re

Remove dead code and clean imports