/*
 *	EasyScout Boy Scouts of America tracking software.
 *	http://www.easyscout.org/
 *
 *	Copyright (C) 2000 Conan C. Albrecht
 *	conan@warp.cx
 *
 *	This program is released under the GNU license so tech-savvy
 *	Boy Scouts and others can enhance the program for the use
 *	of all.  Please e-mail changes to my address above so I can
 *	reintegrate into the main program at http://www.easyscout.org/.
 *	This way, all users mutually benefit one another in the spirit of
 *	scouting.
 *
 *	This program is free software; you can redistribute it and/or
 *	modify it under the terms of the GNU General Public License
 *	as published by the Free Software Foundation; either version 2
 *	of the License, or (at your option) any later version.
 *
 * 	Any and all changes to the program code must be documented with
 *  date, author name and e-mail, and a short description.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

package cx.warp.scout;

import java.io.*;
import javax.servlet.http.*;

/** The top-level gateway to application data.
		Interfaces to the data are used to allow the system to be portable
		across file persistence schemes.  For example, right now the program
		uses simple files to save troops.  This works fine and is nice since
		it is much simpler (and less error prone) than databases.  However,
		if the program ever gets a large user base, we will have to switch
		to a real database.  At that time, all we have to do is implement
		new classes that meet the Data interfaces and the program should
		work perfectly without any changes.
 */
public interface DataGate {
	
	/** Initialization -- called upon servlet creation */
	public void init() throws DataException;
	
	/** Creates a new troop, returning a reference to the new troop */
	public Troop createTroop(String name, String password) throws DataException;
	
	/** Returns the given troop, or null if this troop does not exist */
	public Troop getTroop(String name, PrintWriter out) throws DataException;
	
	/** Prints client information */
	public void printClients(HttpServletRequest request, PrintWriter out, Session session) throws DataException;

	/** Informs a DataGate that a Troop is in use (for caching purposes) */
	public void cacheTroop(Troop troop) throws DataException;
	
	/** Validates the root password */
	public boolean validateRoot(String password);

}//DataGate
